public ActionResult Create(JournalVFormatModel model) { if (ModelState.IsValid) { EHMSEntities ent = new EHMSEntities(); var data = ent.JornalVFormats.Where(m => m.JVFormat == model.JVFormat).Select(m => m.JVId).ToList(); //var dataa = ent.SetupBlock.Where(m => m.BlockName == model.BlockName).Count(); if (data.Count == 0) { int i = JVFPro.Insert(model); if (i != null) { TempData["success"] = HospitalManagementSystem.UtilityMessage.save; return(RedirectToAction("Index")); } else { TempData["success"] = HospitalManagementSystem.UtilityMessage.savefailed; return(RedirectToAction("Index")); } } else { TempData["success"] = HospitalManagementSystem.UtilityMessage.AlreadyExist; return(RedirectToAction("Index")); } } return(View()); }
public int Update(JournalVFormatModel model) { int i = 0; using (EHMSEntities ent = new EHMSEntities()) { var objToEdit = ent.JornalVFormats.Where(x => x.JVId == model.JVId).FirstOrDefault(); AutoMapper.Mapper.Map(model, objToEdit); objToEdit.JVFormat = objToEdit.Prefix + "-" + objToEdit.FiscalYear + "-" + objToEdit.Postfix; ent.Entry(objToEdit).State = System.Data.EntityState.Modified; i = ent.SaveChanges(); } return(i); }
public ActionResult Edit(int id, JournalVFormatModel model) { if (ModelState.IsValid) { int i = JVFPro.Update(model); if (i != null) { TempData["success"] = HospitalManagementSystem.UtilityMessage.edit; return(RedirectToAction("Index")); } else { TempData["success"] = HospitalManagementSystem.UtilityMessage.editfailed; return(RedirectToAction("Index")); } //return View(model); } return(View(model)); }
public int Insert(JournalVFormatModel model) { int i = 0; using (EHMSEntities ent = new EHMSEntities()) { var objList = ent.JornalVFormats.ToList(); foreach (var item in objList) { item.IsCurrent = "N"; ent.Entry(item).State = System.Data.EntityState.Modified; ent.SaveChanges(); } var objToSave = AutoMapper.Mapper.Map <JournalVFormatModel, JornalVFormat>(model); objToSave.IsCurrent = "Y"; objToSave.JVFormat = objToSave.Prefix + "-" + objToSave.FiscalYear + "-" + objToSave.Postfix; ent.JornalVFormats.Add(objToSave); i = ent.SaveChanges(); } return(i); }
public ActionResult Edit(int id) { model = JVFPro.GetList().Where(x => x.JVId == id).FirstOrDefault(); return(View(model)); }