public ActionResult Create(AppointmentCreateViewModel model, string redirectUrl) { if (!ModelState.IsValid) { var dentists = UserManager.Users.Where(x => x.TypeUser == UserType.Dentist).Select(t => new SelectListItem { Text = t.FirstName + " " + t.LastName + " " + t.MiddleName, Value = (t.Id).ToString() }).ToList(); var patients = Patients.Get().Select(s => new SelectListItem { Text = s.LastName + " " + s.FirstName + " " + s.MiddleName, Value = Convert.ToString(s.PatientsId) }).ToList(); model.Users = patients; model.Patients = dentists; return(View(model)); } var app = new Appointments { PatientId = model.PatientId, UserId = model.UserId, AppointmentStatus = Status.Pending, VisitDate = model.VisitDate }; Appointment.Create(app); return(RedirectToLocal(redirectUrl)); }
public void CreateAppointmentTest() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Create_Appointment") .Options; var appointment = new Appointment { Id = 1 }; var user = new UserProfile { Id = "userId" }; var agency = new AgencyProfile { Id = "agencyId" }; var ad = new Ad { Id = 2 }; var date = DateTime.UtcNow; int count; using (var db = new ApplicationDbContext(options)) { AppointmentService service = new AppointmentService(db); service.Create(ad, user, agency, date); count = db.Appointments.Count(); } Assert.Equal(1, count); }
public ActionResult Create([Bind("Id,Data,Ora,NumeClient,Telefon,Marca,Descriere,Status")] Appointment appointment) { if (ModelState.IsValid) { appService.Create(appointment); return(RedirectToAction(nameof(Index))); } return(View(appointment)); }
public ActionResult Create([Bind("Id,Date,Client,Phone,Car,Problem,Status")] Appointment appointment) { if (ModelState.IsValid) { appService.Create(appointment); appService.Save(); return(RedirectToAction("Index")); } return(View(appointment)); }
public async Task CreateShouldWorkCorrectly() { this.SetupSqlite(); await this.SeedDatabase(); using var context = new ApplicationDbContext(this.ContextOptions); var repository = new EfDeletableEntityRepository <Appointment>(context); var appointmentService = new AppointmentService(repository); var appointmentId = await appointmentService.Create(new AppointmentServiceModel()); Assert.True(appointmentId == (this.GetTestAppointments().Length + 1)); }
public ActionResult <Appointment> Create(Appointment Appointment) { _AppointmentService.Create(Appointment); return(CreatedAtRoute("GetAppointment", new { id = Appointment.Id.ToString() }, Appointment)); }
public Appointment Create(Appointment entity) => _appointmentService.Create(entity);
public List <AppointmentModel> Add(AppointmentModel model) { service.Create(model); return(GetAll()); }