public ActionResult ComplainType() { List <ComplainType> CategoryList = new List <ComplainType>(); Property p = new Property(); DataSet ds = new DataSet(); p.OnTable = "FetchComplainType"; ds = dl.FetchComplainType_sp(p); try { foreach (DataRow item in ds.Tables[0].Rows) { ComplainType m = new ComplainType(); m.CId = item["CId"].ToString(); m.CType = item["CType"].ToString(); m.AddedBy = item["AddedBy"].ToString(); m.Description = item["Description"].ToString(); m.IsActive = item["IsActive"].ToString(); CategoryList.Add(m); } ViewBag.CategoryList = CategoryList; } catch (Exception e) { } return(View()); }
//[ValidateAntiForgeryToken] public ActionResult UpdateComplainType(ComplainType ComplainTypeInfoForUpdate) { try { ComplainType band_Check = db.ComplainType.Where(s => s.ComplainTypeID != ComplainTypeInfoForUpdate.ComplainTypeID && s.ComplainTypeName == ComplainTypeInfoForUpdate.ComplainTypeName.Trim()).FirstOrDefault(); if (band_Check != null) { //TempData["AlreadyInsert"] = "ComplainType Already Added. Choose different ComplainType. "; return(Json(new { UpdateSuccess = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } var ComplainType_db = db.ComplainType.Where(s => s.ComplainTypeID == ComplainTypeInfoForUpdate.ComplainTypeID); ComplainTypeInfoForUpdate.CreatedBy = ComplainType_db.FirstOrDefault().CreatedBy; ComplainTypeInfoForUpdate.CreatedDate = ComplainType_db.FirstOrDefault().CreatedDate; ComplainTypeInfoForUpdate.UpdateBy = AppUtils.GetLoginEmployeeName(); ComplainTypeInfoForUpdate.UpdateDate = AppUtils.GetDateTimeNow(); db.Entry(ComplainType_db.SingleOrDefault()).CurrentValues.SetValues(ComplainTypeInfoForUpdate); db.SaveChanges(); TempData["UpdateSucessOrFail"] = "Update Successfully."; var ComplainTypes = ComplainType_db.Select(s => new { ComplainTypeID = s.ComplainTypeID, PackageName = s.ComplainTypeName, ShowMessageBox = s.ShowMessageBox == true ? "Yes":"No" }); var JSON = Json(new { UpdateSuccess = true, ComplainTypeUpdateInformation = ComplainTypes }, JsonRequestBehavior.AllowGet); JSON.MaxJsonLength = int.MaxValue; return(JSON); } catch { TempData["UpdateSucessOrFail"] = "Update Fail."; return(Json(new { UpdateSuccess = false, ComplainTypeUpdateInformation = "" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult ComplainType(ComplainType c) { HttpCookie rxgoAdminCookie = Request.Cookies["rxgoAdmin"]; string AddedBy = rxgoAdminCookie.Values["Hid"]; c.AddedBy = AddedBy; try { if (dl.InsertComplainType_Sp(c) > 0) { TempData["MSG"] = "Compalin Type Added Successfully"; } } catch (Exception ex) { TempData["MSG"] = "Something went wrong."; return(Redirect("/FrontOffice/ComplainType")); } TempData["MSG"] = "Compalin Type Added Successfully."; return(Redirect("/FrontOffice/ComplainType")); }
public ActionResult InsertComplainTypeFromPopUp(ComplainType ComplainType_Client) { ComplainType band_Check = db.ComplainType.Where(s => s.ComplainTypeName == ComplainType_Client.ComplainTypeName.Trim()).FirstOrDefault(); if (band_Check != null) { // TempData["AlreadyInsert"] = "ComplainType Already Added. Choose different ComplainType. "; return(Json(new { SuccessInsert = false, AlreadyInsert = true }, JsonRequestBehavior.AllowGet)); } ComplainType ComplainType_Return = new ComplainType(); try { ComplainType_Client.CreatedBy = AppUtils.GetLoginEmployeeName(); ComplainType_Client.CreatedDate = AppUtils.GetDateTimeNow(); ComplainType_Return = db.ComplainType.Add(ComplainType_Client); db.SaveChanges(); if (ComplainType_Return.ComplainTypeID > 0) { // TempData["SaveSucessOrFail"] = "Save Successfully."; return(Json(new { SuccessInsert = true, ComplainType = ComplainType_Return }, JsonRequestBehavior.AllowGet)); } else { // TempData["SaveSucessOrFail"] = "Save Failed."; return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet)); } }