public ActionResult SetDetail() { int id = Request.Form["GroupId"].ParseInt(); TblCustomerGroup ob = uow.Modules.CustomerGroup.Get(id); if (ob.GroupId <= 0) { ob.CreatedBy = CurrentUID; ob.CreatedDate = CurrentDate; } ob.GroupName = Request.Form["GroupName"]; ob.GroupOrder = Request.Form["GroupOrder"].ParseInt(); ob.UpdatedBy = CurrentUID; ob.UpdatedDate = CurrentDate; try { //Validate model b4 save uow.Modules.CustomerGroup.Set(ob); uow.SaveChanges(); return(RedirectToAction("Index", new { area = "", controller = MVCController, msg = "บันทึกข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success })); } catch (Exception ex) { string msg = ex.GetMessage(true); return(ViewDetail(ob, msg, AlertMsgType.Danger)); } }
private ActionResult ViewDetail(TblCustomerGroup ob, string msg, AlertMsgType?msgType) { try { if (ob == null) { throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง"); } if (!string.IsNullOrWhiteSpace(msg)) { WidgetAlertModel alert = new WidgetAlertModel() { Message = msg }; if (msgType.HasValue) { alert.Type = msgType.Value; } ViewBag.Alert = alert; } return(View(ob)); } catch (Exception ex) { return(RedirectToAction("Index", MVCController, new { area = MVCArea, msg = ex.GetMessage(), msgType = AlertMsgType.Danger })); } }
public ActionResult Delete() { try { int id = Request.Form["GroupId"].ParseInt(); TblCustomerGroup ob = uow.Modules.CustomerGroup.Get(id); if (ob == null) { return(RedirectToAction("Index", MVCController, new { msg = "ไม่พบข้อมูลที่ต้องการ", msgType = AlertMsgType.Warning })); } uow.Modules.CustomerGroup.Delete(ob); uow.SaveChanges(); return(RedirectToAction("Index", MVCController, new { msg = "ลบข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success })); } catch (Exception ex) { return(RedirectToAction("Index", MVCController, new { msg = ex.GetMessage(), msgType = AlertMsgType.Danger })); } }
public ActionResult Detail(int?id, string msg, AlertMsgType?msgType) { TblCustomerGroup ob = uow.Modules.CustomerGroup.Get(id ?? 0); return(ViewDetail(ob, msg, msgType)); }