public ActionResult EditWellCompletionType(int id) { var wellCompletionType = new WellCompletionType(); try { if (id < 1) { wellCompletionType.Error = "Invalid Selection!"; wellCompletionType.ErrorCode = -1; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } var myViewObj = new WellCompletionTypeServices().GetWellCompletionType(id); if (myViewObj == null || myViewObj.WellCompletionTypeId < 1) { wellCompletionType.Error = "Well Completion Type Information could not be retrieved."; wellCompletionType.ErrorCode = -1; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } Session["_wellCompletionType"] = myViewObj; myViewObj.ErrorCode = myViewObj.WellCompletionTypeId; return(Json(myViewObj, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); wellCompletionType.Error = "An unknown error was Well Completion Type Information could not be retrieved."; wellCompletionType.ErrorCode = -1; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } }
public ActionResult WellCompletionTypes() { var wellCompletionTypeList = new WellCompletionTypeServices().GetAllOrderedWellCompletionTypes() ?? new List <WellCompletionType>(); if (!wellCompletionTypeList.Any()) { ViewBag.Title = "Well Completion Type SetUp"; return(View(wellCompletionTypeList)); } ViewBag.Title = "Manage Well Completion Types"; return(View(wellCompletionTypeList)); }
public ActionResult AddWellCompletionType(WellCompletionType wellCompletionType) { ModelState.Clear(); ViewBag.LoadStatus = "0"; try { if (!ModelState.IsValid) { wellCompletionType.Error = "Please supply all required fields and try again"; wellCompletionType.ErrorCode = -1; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } var wx = ValidateControl(wellCompletionType); if (wx.Code < 1) { wellCompletionType.Error = wx.Error; wellCompletionType.ErrorCode = -1; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } var k = new WellCompletionTypeServices().AddWellCompletionTypeCheckDuplicate(wellCompletionType); if (k < 1) { if (k == -3) { wellCompletionType.Error = "Well Completion Type already exists"; wellCompletionType.ErrorCode = 0; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } wellCompletionType.Error = "Process Failed! Please contact the Admin or try again later"; wellCompletionType.ErrorCode = 0; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } wellCompletionType.Error = "Record was added successfully"; wellCompletionType.ErrorCode = 1; wellCompletionType.WellCompletionTypeId = k; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); wellCompletionType.Error = "An unknown error was encountered. Request could not be serviced. Please try again later."; wellCompletionType.ErrorCode = 0; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } }
public ViewResult WellCompletionIntervals() { var wellCompletionList = new WellCompletionServices().GetAllOrderedWellCompletions() ?? new List <WellCompletion>(); if (!wellCompletionList.Any()) { ViewBag.Edit = 1; ViewBag.Title = "Well Completion SetUp"; var wellCompletionTypeList = new WellCompletionTypeServices().GetAllOrderedWellCompletionTypes() ?? new List <WellCompletionType>(); if (!wellCompletionTypeList.Any()) { ViewBag.Edit = 0; ViewBag.Title = "Well Completion Type SetUp"; return(View("~/Views/WellCompletionType/WellCompletionTypes.cshtml", new List <WellCompletionType>())); } } wellCompletionList.ForEach(m => { m.WellName = m.Well.Name; m.WellCompletionTypeName = m.WellCompletionType.Type; m.EquipmentName = m.Equipment.Name; }); var wellCompletionIntervalList = new WellCompletionIntervalServices().GetAllOrderedWellCompletionIntervals() ?? new List <WellCompletionInterval>(); if (!wellCompletionIntervalList.Any()) { ViewBag.Edit = 0; ViewBag.Title = "Well Completion Interval SetUp"; return(View(Tuple.Create(wellCompletionList, new List <WellCompletionInterval>()))); } wellCompletionIntervalList.ForEach(m => { m.DatecomPletedString = m.DateCompleted; m.WellName = wellCompletionList.Find(x => x.WellId == m.WellCompletion.WellId).Well.Name; }); var txx = Tuple.Create(wellCompletionList, wellCompletionIntervalList); ViewBag.Title = "Manage Well Completion Intervals"; return(View(txx)); }
public ActionResult EditWellCompletionType(WellCompletionType wellCompletionType) { ModelState.Clear(); ViewBag.LoadStatus = "0"; try { if (Session["_wellCompletionType"] == null) { wellCompletionType.Error = "Session has expired"; wellCompletionType.ErrorCode = 0; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } var oldWellCompletionType = Session["_wellCompletionType"] as WellCompletionType; if (oldWellCompletionType == null || oldWellCompletionType.WellCompletionTypeId < 1) { wellCompletionType.Error = "Session has expired"; wellCompletionType.ErrorCode = 0; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } if (!ModelState.IsValid) { wellCompletionType.Error = "Please supply all required fields and try again"; wellCompletionType.ErrorCode = -1; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } var wx = ValidateControl(wellCompletionType); if (wx.Code < 1) { wellCompletionType.Error = wx.Error; wellCompletionType.ErrorCode = -1; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } oldWellCompletionType.Type = wellCompletionType.Type; var k = new WellCompletionTypeServices().UpdateWellCompletionTypeCheckDuplicate(oldWellCompletionType); if (k < 1) { if (k == -3) { wellCompletionType.Error = "Well Completion Type already exists"; wellCompletionType.ErrorCode = 0; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } wellCompletionType.Error = "Process Failed! Please contact the Admin or try again later"; wellCompletionType.ErrorCode = 0; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } wellCompletionType.Error = "Well Completion Type Information was successfully updated"; wellCompletionType.ErrorCode = 1; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); wellCompletionType.Error = "An unknown error was encountered. Request could not be serviced. Please try again later."; wellCompletionType.ErrorCode = 0; return(Json(wellCompletionType, JsonRequestBehavior.AllowGet)); } }