public ActionResult Edit(SetupBilllingTypeModel model) { try { if (ModelState.IsValid) { int i = pro.Update(model); if (i != 0) { TempData["success"] = UtilityMessage.edit; } else { TempData["success"] = UtilityMessage.editfailed; } return(RedirectToAction("Index")); } return(View()); } catch { TempData["success"] = "Error occur"; return(RedirectToAction("Index")); } }
// // GET: /SetupBillingType/ public ActionResult Index() { SetupBilllingTypeModel model = new SetupBilllingTypeModel(); model.SetupBillingTypeList = pro.GetList(); return(View(model)); }
public int Update(SetupBilllingTypeModel model) { using (EHMSEntities ent = new EHMSEntities()) { var item = ent.SetupBillingTypes.Where(x => x.SetupBillingTypeName == model.SetupBillingTypeName && x.SetupBillingTypeID != model.SetupBillingTypeID); if (item.Count() == 0) { var objToUpdate = ent.SetupBillingTypes.Where(x => x.SetupBillingTypeID == model.SetupBillingTypeID).FirstOrDefault(); model.CreatedBy = objToUpdate.CreatedBy; model.CreatedDate = objToUpdate.CreatedDate; AutoMapper.Mapper.Map(model, objToUpdate); ent.Entry(objToUpdate).State = System.Data.EntityState.Modified; int i = ent.SaveChanges(); return(i); } else { return(0); } } }
public int Insert(SetupBilllingTypeModel model) { using (EHMSEntities ent = new EHMSEntities()) { var item = ent.SetupBillingTypes.Where(x => x.SetupBillingTypeName == model.SetupBillingTypeName); if (item.Count() == 0) { var objToSave = AutoMapper.Mapper.Map <SetupBilllingTypeModel, SetupBillingType>(model); objToSave.CreatedBy = 0; objToSave.CreatedDate = DateTime.Now; ent.SetupBillingTypes.Add(objToSave); int i = ent.SaveChanges(); return(i); } else { return(0); } } }
//Get: /SetupBillingType/Edit public ActionResult Edit(int id) { SetupBilllingTypeModel model = pro.GetList().Where(x => x.SetupBillingTypeID == id).FirstOrDefault(); return(View(model)); }