Coder Social home page Coder Social logo

zxc1221 / appointment-scheduling Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saimedavarapu/appointment-scheduling

0.0 0.0 0.0 9.27 MB

Full stack application built using ASP.NET Core, EF Core, SSMS and Angular. This lets the user schedule an appointment and Perform CRUD on it.

License: MIT License

JavaScript 4.14% C# 28.40% TypeScript 34.62% CSS 3.63% HTML 29.21%

appointment-scheduling's Introduction

Appointment-Scheduling

Full stack application built using ASP.NET Core, EF Core, SSMS and Angular. This lets the user schedule an appointment and Perform CRUD on it.

  • Click ⭐if you like the project. Pull Request are highly appreciated.

Running guide

Download the zip. Open Appointment.sln and run IIS Express.

Project description :

Appointment scheduling lets Admin(For now) to schedule the appointment for a particular date and time. The admin can later update and delete the appointment on demand.

Patterns used:

  • Dependency Injection Pattern
  • Singleton pattern
  • PUBSUB Pattern

Angular features:

  • Reactive forms
  • Components
  • services
  • Pipes
  • Angular routing
  • Dependency Injection
  • Observables from rxjs

Documentation:

Client Side using Angular.

Following is the customer model.

    
export interface customerModel {
  appointmentDate: string;
  appointmentID: number;
  dateOfBirth: string;
  firstName: string;
  lastName: string;
}
  • Reactive form for the customer details. Createthe following form in the ngoninit.
 this.customerForm = this.fb.group({
      FirstName: ['', [Validators.required, Validators.minLength(2), Validators.maxLength(50)]],
      LastName: ['', [Validators.required, Validators.minLength(2), Validators.maxLength(50)]],
      DateOfBirth: [''],
      AppointmentTime: ['']
    });
  • Service is created to make the calls to the API which returns an observable which can be subscribed to when needed.
@Injectable()
export class HomeService {

  constructor(private http: HttpClient) { }


  CreateAppointment(data: string): Observable<any> {
    return this.http.post("https://localhost:44396/api/SampleData/CreateAppointment", data);
  }


  GetAppointment(appointmentId: any): Observable<any> {
    return this.http.get("https://localhost:44396/api/SampleData/" + appointmentId );
  }

  UpdateAppointment(data: string): Observable<any> {
    return this.http.post("https://localhost:44396/api/SampleData/UpdateTodoItem", data);
  }


  DeleteAppointment(data: string): Observable<any> {
    console.log("reached delete appointment");
    return this.http.post("https://localhost:44396/api/SampleData/DeleteAppointment", data);
  }
  }
  • Subscribing to the service in the type script file: When the service is created, it can be injected into the component using dependency injection. Which can be subsrcbed by using .subsrcibe method by using PUBSUB pattern .
 onSubmit(): void {
  console.log(this.customerForm.value);
  var data = this.customerForm.value;
  this.homeService.CreateAppointment(data).subscribe(
    result => {
      console.log(result);
    }
  )
  • Similarly, code can be found inside the ClientApp folder for deleting and updating the appointments.

Web API using .NET core, EF core, C#, LINQ:

 [HttpPost("[action]")]
     public async Task<ActionResult<int>> CreateAppointment([FromBody] Entities.Appointment item)
     {
         try
         {
             _context.Appointments.Add(item);
             var result = await _context.SaveChangesAsync();

             //Sending email

             var message = new MimeMessage();
             //From Address
             message.From.Add(new MailboxAddress("sai vaibhav medavarapu", "[email protected]"));

             //To address
             message.To.Add(new MailboxAddress("S Medavarapu", "[email protected]"));
             //Subject
             message.Subject = "Appointment confirmed";
             //Body
             message.Body = new TextPart("plain")
             {
                 Text = "Appointment confirmed"
             };


             //Configure and send the email

             using (var client = new SmtpClient())
             {
                 // For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS)
                 client.ServerCertificateValidationCallback = (s, c, h, e) => true;

                 client.Connect("smtp.gmail.com", 587, false);

                 // Note: only needed if the SMTP server requires authentication
                 client.Authenticate("Your Username", "your password");

                 client.Send(message);
                 client.Disconnect(true);
             }
             return item.AppointmentID;
         }
         catch (Exception ex)
         {

         }
         return null;
     }

For delete operation

     public async Task<ActionResult<Entities.Appointment>> DeleteAppointment([FromBody]Entities.Appointment item)
     {
         try
         {

             var student = await _context.Appointments.FirstOrDefaultAsync(b => b.AppointmentID == item.AppointmentID);
             _context.Appointments.Remove(student);
             await _context.SaveChangesAsync();
             return NoContent();
         }
         catch (Exception ex)
         {

         }
         return null;
     }
 ```

appointment-scheduling's People

Contributors

saimedavarapu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.