public ActionResult Create(BookingCosmeticServiceModel bookingCosmeticServiceModel) { if (!ModelState.IsValid) { return(View("Create", bookingCosmeticServiceModel)); } ; BookingCosmeticService bookingCosmeticService = new BookingCosmeticService(); if (bookingCosmeticServiceModel.ServiceId != null) { Console.WriteLine("Error"); } bookingCosmeticService.ServiceId = bookingCosmeticServiceModel.ServiceId.HasValue ? bookingCosmeticServiceModel.ServiceId.Value : 0; bookingCosmeticService.Nameservice = bookingCosmeticServiceModel.Nameservice; bookingCosmeticService.Price = bookingCosmeticServiceModel.Price; bookingCosmeticService.VisitData = bookingCosmeticServiceModel.VisitData; bookingCosmeticService.MasterName = bookingCosmeticServiceModel.MasterName; bookingCosmeticService.FirstName = bookingCosmeticServiceModel.FirstName; bookingCosmeticService.LastName = bookingCosmeticServiceModel.LastName; bookingCosmeticService.Phone = bookingCosmeticServiceModel.Phone; cosmeticServiceService.Create(bookingCosmeticService); return(RedirectToAction("Index")); }
public void Edit(BookingCosmeticService bookingCosmeticService) { //1 databaseContex.Entry(bookingCosmeticService).State = EntityState.Modified; //2 // databaseContex.Update(cosmeticService); databaseContex.SaveChanges(); }
public ActionResult Update(BookingCosmeticServiceModel bookingCosmeticServiceModel) { if (!ModelState.IsValid) { return(View("Update", bookingCosmeticServiceModel)); } ; BookingCosmeticService bookingCosmeticService = new BookingCosmeticService(); bookingCosmeticService.Id = bookingCosmeticServiceModel.Id.HasValue ? bookingCosmeticServiceModel.Id.Value : 0; bookingCosmeticService.Nameservice = bookingCosmeticServiceModel.Nameservice; bookingCosmeticService.Price = bookingCosmeticServiceModel.Price; bookingCosmeticService.VisitData = bookingCosmeticServiceModel.VisitData; bookingCosmeticService.MasterName = bookingCosmeticServiceModel.MasterName; bookingCosmeticService.FirstName = bookingCosmeticServiceModel.FirstName; bookingCosmeticService.LastName = bookingCosmeticServiceModel.LastName; bookingCosmeticService.Phone = bookingCosmeticServiceModel.Phone; cosmeticServiceService.Edit(bookingCosmeticService); return(RedirectToAction("Index")); }
public void Create(BookingCosmeticService bookingCosmeticService) { databaseContex.BookingCosmeticServices.Add(bookingCosmeticService); databaseContex.SaveChanges(); }