public ActionResult Save(Appointment appointment) { if (!ModelState.IsValid) { var vm = new NewAppointmentViewModel(appointment) { Products = _context.Products.ToList() }; return(View("Create", vm)); } if (appointment.Id == 0) { _context.Appointments.Add(appointment); _context.SaveChanges(); return(RedirectToAction("Done", "Appointments")); } else { var aptInDB = _context.Appointments.Single(a => a.Id == appointment.Id); aptInDB.PersonName = appointment.PersonName; aptInDB.PhoneNumber = appointment.PhoneNumber; aptInDB.Email = appointment.Email; aptInDB.Date = appointment.Date; aptInDB.IsConfirmed = appointment.IsConfirmed; aptInDB.PId = appointment.PId; _context.SaveChanges(); return(RedirectToAction("Index", "Appointments")); } }
public override void Start() { base.Start(); ReloadDataAsync().Forget(); NewAppointmentViewModel.Start(); }
public ActionResult New() { var product1 = _context.Products.ToList(); var viewModel = new NewAppointmentViewModel { Product = product1 }; return(View(viewModel)); }
public ActionResult Create() { var product = _context.Products.ToList(); var vm = new NewAppointmentViewModel { Products = product }; return(View(vm)); }
public IActionResult Create(NewAppointmentViewModel model) { if (!ModelState.IsValid) { return(PartialView("_Create", model)); } AddAppointment(model); return(PartialView("_Create", model)); }
public ActionResult Create() { HttpResponseMessage response1 = GlobalVar.webApiClient.GetAsync("Product").Result; var viewModel = new NewAppointmentViewModel { Products = response1.Content.ReadAsAsync <IEnumerable <Product> >().Result }; return(View(viewModel)); }
public void GivenNewAppointmentWhenInvalidLocationLengthThenReturnsInvalid() { var model = new NewAppointmentViewModel() { Location = new string('-', 256) }; NewAppointmentValidator validator = new NewAppointmentValidator(); FluentValidation.Results.ValidationResult results = validator.Validate(model); Assert.That(results.IsValid, Is.False); Assert.That(results.Errors.Any(x => x.PropertyName == nameof(NewAppointmentViewModel.Location)), Is.True); }
public void GivenNewAppointmentWhenEndDateBeforeStartDateThenReturnsInvalid() { var model = new NewAppointmentViewModel() { StartDate = DateTime.Today, EndDate = DateTime.Today.AddDays(-1) }; NewAppointmentValidator validator = new NewAppointmentValidator(); FluentValidation.Results.ValidationResult results = validator.Validate(model); Assert.That(results.IsValid, Is.False); Assert.That(results.Errors.Any(x => x.PropertyName == nameof(NewAppointmentViewModel.EndDate)), Is.True); }
public ActionResult MakeNewAppointment(int doctorId) { int patientId = User.Identity.GetUserId <int>(); newAppointmentViewModel = new NewAppointmentViewModel(doctorId, (int)patientId); SelectList days = new SelectList(newAppointmentViewModel.daysOfWeek.ToList(), "Number", "DayTitle", 1); ViewBag.Days = days; SelectList hours = new SelectList(newAppointmentViewModel.daysOfWeek[1].Times); ViewBag.Hours = hours; return(View(newAppointmentViewModel)); }
public async Task <AppointmentViewModel> Create(NewAppointmentViewModel newAppointmentViewModel) { var appointment = _mapper.Map <Appointment>(newAppointmentViewModel); _appointmentValidation.ValidationOnCreating(appointment); await _appointmentRepository.InsertAsync(appointment); await _appointmentRepository.SaveChangesAsync(); var result = await GetById(appointment.Id); return(result); }
public ActionResult Edit(int id) { var apt = _context.Appointments.SingleOrDefault(a => a.Id == id); if (apt == null) { return(HttpNotFound()); } var vm = new NewAppointmentViewModel(apt) { Products = _context.Products.ToList() }; return(View("Create", vm)); }
public ActionResult Edit(int id) { Appointment appointment; HttpResponseMessage response = GlobalVar.webApiClient.GetAsync($"Appointments/{id}").Result; appointment = response.Content.ReadAsAsync <Appointment>().Result; HttpResponseMessage response1 = GlobalVar.webApiClient.GetAsync("Product").Result; var viewModel = new NewAppointmentViewModel(appointment) { Products = response1.Content.ReadAsAsync <IEnumerable <Product> >().Result }; return(View("Create", viewModel)); }
public IHttpActionResult Book(NewAppointmentViewModel model) { try { var identity = (ClaimsIdentity)User.Identity; string accountId = identity.Claims.FirstOrDefault(c => c.Type.Equals("AccountId")).Value; model.AccountId = accountId; _apmServices.BookAppoint(model); return(Ok("Book Success")); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); return(BadRequest("Book Failed")); } }
//public ActionResult Edit(int id) //{ // //var updateCust = _context.Appointments.SingleOrDefault(c => c.Id == id); // var edit = _context.Products.ToList(); // //if (updateC == null) // //{ // // return HttpNotFound(); // //} // var vm = new NewAppointmentViewModel // { // // Appointment = updateCust, // Product = edit // }; // return View("New",vm); //} public ActionResult Edit(int id) { var obj = _context.Appointments.SingleOrDefault(c => c.AId == id); if (obj == null) { return(HttpNotFound()); } var vm = new NewAppointmentViewModel { Appointment = obj, Product = _context.Products.ToList() }; return(View("New", vm)); }
public async Task <IActionResult> Create([FromBody] NewAppointmentViewModel newAppointmentViewModel) { try { if (!ModelState.IsValid) { return(BadRequest()); } var result = await _appointmentAppService.Create(newAppointmentViewModel); return(Ok(result)); } catch (ArgumentException ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message)); } }
public ActionResult Edit(int id) { var updateCust = _context.Appointments.SingleOrDefault(c => c.Id == id); var edit = _context.Products.ToList(); if (updateCust == null) { return(HttpNotFound()); } var vm = new NewAppointmentViewModel { Appointment = updateCust, Product = edit }; return(View(vm)); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { this.MyViewModel = (NewAppointmentViewModel)this.DataContext; MyBlDoctor = new blDoctor(); dbDoctorSearch = new blDoctorSearch(MyBlDoctor); dbPatientSearch = new blPatSearch(); srcDoctore.DataProvider = this.dbDoctorSearch; srcPatient.DataProvider = this.dbPatientSearch; //BlPatient abc = new BlPatient(); //dhPatient TestObj = new dhPatient(); //TestObj.vFullName = "saqib Ali"; //TestObj.vGender = "Male"; //TestObj.iPatAge = 14; //TestObj.bActive = true; //abc.AddNewPatient(TestObj); this.AppointmentInfo.DataContext = new dhAppointment(); this.PatientInformationGrid.DataContext = new dhPatient(); }
public ActionResult Save(Appointment appointment) { if (!ModelState.IsValid) { HttpResponseMessage response1 = GlobalVar.webApiClient.GetAsync("Product").Result; var viewModel = new NewAppointmentViewModel(appointment) { Products = response1.Content.ReadAsAsync <IEnumerable <Product> >().Result }; return(View("Create", viewModel)); } if (appointment.Id == 0) { HttpResponseMessage response = GlobalVar.webApiClient.PostAsJsonAsync("Appointments", appointment).Result; } else { HttpResponseMessage response = GlobalVar.webApiClient.PutAsJsonAsync($"Appointments/{appointment.Id}", appointment).Result; } return(RedirectToAction("Index", "Appointments")); }
public ActionResult Create(Appointment appointment) { var create = _context.Products.ToList(); //if (updateC == null) //{ // return HttpNotFound(); //} var vm = new NewAppointmentViewModel { // Appointment = updateCust, Product = create, }; _context.Appointments.Add(appointment); return(RedirectToAction("Index")); //return View(vm); }
public void BookAppoint(NewAppointmentViewModel model) { var customerId = _customerRepo.Gets().Where(p => p.AccountId == model.AccountId).Select(x => x.CustomerId).FirstOrDefault(); var startTime = DateTime.Parse(model.StartTime); model.CustomerId = customerId; var bookedServices = _salonServiceRepo.Gets() .Where(s => model.Services.Contains(s.Id)) .Select(x => new ServiceAppointment { Price = x.Price ?? 0, ServiceId = x.Id, }).ToList(); var apm = new Appointment { BookedDate = DateTime.Now, CustomerId = model.CustomerId, PromotionId = model.PromotionId, Duration = model.Duration, Status = AppointmentStatusConstant.NOTAPPROVE, StartTime = startTime, ServiceAppointment = bookedServices }; // UPDATE SLOTS TO SLOT TIME var slot = _slotTimeRepo.GetByID(model.SlotId); foreach (var index in model.Indexes) { var capacity = slot.GetType().GetProperty($"Slot{index}").GetValue(slot); byte cap = Convert.ToByte(capacity); cap += 1; slot.GetType().GetProperty($"Slot{index}").SetValue(slot, cap); } _slotTimeRepo.Edit(slot); _apmRepo.Insert(apm); _unitOfWork.SaveChanges(); }
private void AddAppointment(NewAppointmentViewModel appointment) { _appointmentService.Add(_mapper.Map <AppointmentDTO>(appointment)); }