public int Insert(CommonTestSetupModel model) { int i = 0; using (EHMSEntities ent = new EHMSEntities()) { var objToSave = AutoMapper.Mapper.Map <CommonTestSetupModel, HospitalExtraTest>(model); try { objToSave.CreatedBy = Utility.GetCurrentLoginUserId(); objToSave.CreatedDate = DateTime.Now; objToSave.Vat = 0; objToSave.VatAmount = 0; objToSave.CommonTestTypeId = 1; objToSave.Status = true; ent.HospitalExtraTests.Add(objToSave); i = ent.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } } return(i); }
public ActionResult Edit(int id) { CommonTestSetupModel model = new CommonTestSetupModel(); CommonTestSetProvider pro = new CommonTestSetProvider(); model = pro.GetList().Where(x => x.HospitalExtraTestId == id).FirstOrDefault(); return(View(model)); }
// // GET: /CommonTest/ public ActionResult Index() { CommonTestSetProvider pro = new CommonTestSetProvider(); CommonTestSetupModel model = new CommonTestSetupModel(); model.CommonTestList = pro.GetList().Where(x => x.Status == true).ToList(); return(View(model)); }
public ActionResult Edit(CommonTestSetupModel model) { CommonTestSetProvider pro = new CommonTestSetProvider(); int i = pro.Update(model); if (i != 0) { TempData["success"] = HospitalManagementSystem.UtilityMessage.edit; return(RedirectToAction("index")); } return(View(model)); }
public ActionResult Create(CommonTestSetupModel model) { CommonTestSetProvider pro = new CommonTestSetProvider(); int i = pro.Insert(model); if (i != 0) { TempData["success"] = HospitalManagementSystem.UtilityMessage.save; return(RedirectToAction("Index")); } return(View()); }
public int Update(CommonTestSetupModel model) { int i = 0; using (EHMSEntities ent = new EHMSEntities()) { var objToEdit = ent.HospitalExtraTests.Where(x => x.HospitalExtraTestId == model.HospitalExtraTestId).FirstOrDefault(); model.CommonTestTypeId = 1; AutoMapper.Mapper.Map(model, objToEdit); ent.Entry(objToEdit).State = System.Data.EntityState.Modified; i = ent.SaveChanges(); } return(i); }