public void AddMedicalService(MedicalServices medicalService) { using (var context = new RabbitsDBEntities()) { if(IsNameExist(medicalService.MedicalServiceName, context)) throw new InvalidOperationException(AlreadyExist); context.MedicalServices.Add(medicalService); context.SaveChanges(); } }
public ActionResult UpdateMedicalService(MedicalServices medicalService) { try { if (ModelState.IsValid) new MedicalServicesManager().UpdateMedicalService(medicalService); return RedirectToAction(ShowMedicalServicesAction); } catch (InvalidOperationException exception) { return RedirectToAction(ErrorAction, new { exception }); } }
public void UpdateMedicalService(MedicalServices medicalService) { using (var context = new RabbitsDBEntities()) { if (IsNameExist(medicalService.MedicalServiceName, context)) throw new InvalidOperationException(AlreadyExist); var result = context.MedicalServices.FirstOrDefault(x => x.Id == medicalService.Id); if (result == null) throw new InvalidOperationException(NotFound); result.MedicalServiceName = medicalService.MedicalServiceName; context.SaveChanges(); } }
public void UpdateMedicalService(MedicalServices medicalService) { new MedicalServicesRepository().UpdateMedicalService(medicalService); }
public void AddMedicalService(MedicalServices medicalService) { new MedicalServicesRepository().AddMedicalService(medicalService); }