public string EditPayment(PayMode Model) { string msgClient; try { if (ModelState.IsValid) { var enditedPaymentValue = new LMS_Datas.PayMode { Active = true, PayModeId = Model.PayModeId, PayMode1 = Model.PayMode1 }; entity.PayModes.Attach(enditedPaymentValue); entity.Entry(enditedPaymentValue).Property(x => x.PayMode1).IsModified = true; entity.Entry(enditedPaymentValue).State = EntityState.Modified; entity.SaveChanges(); msgClient = "Saved Successfully"; } else { msgClient = "Validation data not successfully"; } } catch (Exception ex) { msgClient = "Error in Retriving Data"; } return(msgClient); }
public ActionResult Index(PayMode model) { try { if (ModelState.IsValid) { using (var context = new LoyaltyManagementSystemEntities()) { var payMode = new LMS_Datas.PayMode() { PayMode1 = model.PayMode1, Active = true }; context.PayModes.Add(payMode); context.SaveChanges(); } } ViewBag.alert = "Success"; return(View()); } catch (Exception e1) { ViewBag.alert = "Error"; return(View()); } }