public ActionResult EditLeaseType(int id) { var incidentType = new LeaseType(); try { if (id < 1) { incidentType.Error = "Invalid Selection!"; incidentType.ErrorCode = -1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } var myViewObj = new LeaseTypeServices().GetLeaseType(id); if (myViewObj == null || myViewObj.LeaseTypeId < 1) { incidentType.Error = "Lease Type Information could not be retrieved."; incidentType.ErrorCode = -1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } Session["_product"] = myViewObj; myViewObj.ErrorCode = myViewObj.LeaseTypeId; return(Json(myViewObj, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); incidentType.Error = "An unknown error was LeaseType Information could not be retrieved."; incidentType.ErrorCode = -1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } }
public ActionResult LeaseTypes() { var productList = new LeaseTypeServices().GetAllOrderedLeaseTypes() ?? new List <LeaseType>(); if (!productList.Any()) { ViewBag.Title = "Lease Type SetUp"; return(View(productList)); } ViewBag.Title = "Manage Incident Types"; return(View(productList)); }
public ActionResult AddLeaseType(LeaseType leaseType) { ModelState.Clear(); ViewBag.LoadStatus = "0"; try { if (!ModelState.IsValid) { leaseType.Error = "Please supply all required fields and try again"; leaseType.ErrorCode = -1; return(Json(leaseType, JsonRequestBehavior.AllowGet)); } var wx = ValidateControl(leaseType); if (wx.Code < 1) { leaseType.Error = wx.Error; leaseType.ErrorCode = -1; return(Json(leaseType, JsonRequestBehavior.AllowGet)); } leaseType.Name = leaseType.Name; var k = new LeaseTypeServices().AddLeaseTypeCheckDuplicate(leaseType); if (k < 1) { if (k == -3) { leaseType.Error = "Lease Type already exists"; leaseType.ErrorCode = -3; return(Json(leaseType, JsonRequestBehavior.AllowGet)); } leaseType.Error = "Process Failed! Please contact the Admin or try again later"; leaseType.ErrorCode = 0; return(Json(leaseType, JsonRequestBehavior.AllowGet)); } leaseType.Error = "Record was added successfully"; leaseType.ErrorCode = 1; leaseType.LeaseTypeId = k; return(Json(leaseType, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); leaseType.Error = "An unknown error was encountered. Request could not be serviced. Please try again later."; leaseType.ErrorCode = 0; return(Json(leaseType, JsonRequestBehavior.AllowGet)); } }
public ActionResult EditLeaseType(LeaseType incidentType) { ModelState.Clear(); ViewBag.LoadStatus = "0"; try { if (Session["_product"] == null) { incidentType.Error = "Session has expired"; incidentType.ErrorCode = 0; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } var oldLeaseType = Session["_product"] as LeaseType; if (oldLeaseType == null || oldLeaseType.LeaseTypeId < 1) { incidentType.Error = "Session has expired"; incidentType.ErrorCode = 0; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } if (!ModelState.IsValid) { incidentType.Error = "Please supply all required fields and try again"; incidentType.ErrorCode = -1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } var wx = ValidateControl(incidentType); if (wx.Code < 1) { incidentType.Error = wx.Error; incidentType.ErrorCode = -1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } oldLeaseType.Name = incidentType.Name.Trim(); oldLeaseType.Description = incidentType.Description.Trim(); var k = new LeaseTypeServices().UpdateLeaseTypeCheckDuplicate(oldLeaseType); if (k < 1) { if (k == -3) { incidentType.Error = "Lease Type already exists"; incidentType.ErrorCode = 0; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } incidentType.Error = "Process Failed! Please contact the Admin or try again later"; incidentType.ErrorCode = 0; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } incidentType.Error = "Lease Type Information was successfully updated"; incidentType.ErrorCode = 1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); incidentType.Error = "An unknown error was encountered. Request could not be serviced. Please try again later."; incidentType.ErrorCode = 0; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } }
private Block ProcessRecord(DataRowView dv, ref string msg) { if (dv == null) { return null; } try { var mInfo = new Block { Name = dv.Row["BlockName(eg:OML150)"].ToString().Trim() }; if (mInfo.Name.Trim().Replace(" ", "").ToLower().Contains("opl")) { mInfo.BlockTypeId = 2; } if (mInfo.Name.Trim().Replace(" ", "").ToLower().Contains("oml")) { mInfo.BlockTypeId = 1; } var companyName = dv.Row["CompanyName"].ToString().Trim(); if (string.IsNullOrEmpty(companyName)) { msg = "Company Name is empty"; return null; } var companyId = new CompanyServices().GetCompanyId(companyName); if (companyId < 1) { msg = "Company information could not be processed."; return null; } mInfo.CompanyId = companyId; var area = dv.Row["Area"].ToString().Trim(); if (!string.IsNullOrEmpty(area)) { float outArea; var areaResult = float.TryParse(area, out outArea); if (areaResult && outArea > 0) { mInfo.Area = outArea; } } var yearOfAward = dv.Row["Year_Of_Award(eg:2010)"].ToString().Trim(); if (!string.IsNullOrEmpty(yearOfAward)) { long outyearOfAward; var yearOfAwardResult = long.TryParse(yearOfAward, out outyearOfAward); if (yearOfAwardResult) { mInfo.YearOfAward = outyearOfAward; } } var leaseTypeName = dv.Row["Lease_Type"].ToString().Trim(); if (string.IsNullOrEmpty(leaseTypeName)) { msg = "Lease Type Name is empty"; return null; } var leaseTypeId = new LeaseTypeServices().GetLeaseTypeIdByName(leaseTypeName); if (leaseTypeId < 1) { return null; } mInfo.LeaseTypeId = leaseTypeId; return mInfo; } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); return null; } }