public ActionResult Create(PeerConsumerClass model) { if (Session["Login"] != null) { LoginSession loginsession = (LoginSession)Session["Login"]; ViewBag.CompanyLogo = loginsession.CompanyLogo; ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType); String actionName = this.ControllerContext.RouteData.Values["action"].ToString(); String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType)); ViewBag.RoleName = loginsession.RoleName; if (String.IsNullOrEmpty(model.ClientID.ToString())) { ModelState.AddModelError("Client", "Please Select Client"); } if (String.IsNullOrEmpty(model.SiteID.ToString())) { ModelState.AddModelError("Site", "Please Select Site"); } if (ModelState.IsValid) { try { model.CreateBy = Convert.ToInt64(loginsession.UserID); if (BAL.PeerConsumerModel.CreatePeerConsumerAverages(model)) { return Json(new { result = 1, message = "Record was successfully Saved!" }); } else { return Json(new { result = 0, message = "Duplicate Energy Supplier " }); } } catch (Exception ex) { return Json(new { result = 0, message = "ErrorMessage" + ":" + ex.StackTrace.ToString() }); } } else { String errorMessage = String.Empty; String exception = String.Empty; foreach (var modelStateVal in ViewData.ModelState.Values) { foreach (var error in modelStateVal.Errors) { errorMessage = error.ErrorMessage; exception = error.Exception.ToString(); } } return Json(new { result = 0, message = "ErrorMessage" + ":" + exception }); } } else { return RedirectToAction("Index", "Home"); } }
public static Boolean UpdatePeerConsumerAverages(PeerConsumerClass peer) { Boolean flag = false; try { Icontext objtext = new BALPeer(); flag = objtext.UpdateRecord(peer); } catch (Exception ex) { throw; } return flag; }
public Object EditRecord(Int64 peerId) { PeerConsumerClass _peer = new PeerConsumerClass(); try { DAL.PeerNConsumerAverage peer = DAL.DALPeer.EditPeerConsumerAverages(Convert.ToInt64(peerId)); _peer.ID = Convert.ToInt64(peer.ID); if (peer.ClientID != null) { _peer.ClientID = Convert.ToInt64(peer.ClientID); } if (peer.SiteID != null) { _peer.SiteID = Convert.ToInt64(peer.SiteID); } if (peer.Percentage != null) { _peer.Percentage = peer.Percentage.ToString(); } if (peer.FormDate != null) { _peer.FromDate = BAL.Common.DateGBString(peer.FormDate.ToString()); } else { _peer.FromDate = null; } if (peer.ToDate != null) { _peer.ToDate = BAL.Common.DateGBString(peer.ToDate.ToString()); } else { _peer.ToDate = null; } if (peer.IsPreviousConsumer == false) { _peer.IsPreviousConsumer = true; } else { _peer.IsPreviousConsumer = false; } if (peer.PreConsPercentage != null) { _peer.PreConsPercentage = peer.PreConsPercentage.ToString(); } if (peer.PreConsFormDate != null) { _peer.PreConsFormDate = BAL.Common.DateGBString(peer.PreConsFormDate.ToString()); } else { _peer.PreConsFormDate = null; } if (peer.PreConsToDate != null) { _peer.PreConsToDate = BAL.Common.DateGBString(peer.PreConsToDate.ToString()); } else { _peer.PreConsToDate = null; } } catch (Exception ex) { throw; } return _peer; }
public ActionResult Update(PeerConsumerClass model) { if (Session["Login"] != null) { try { LoginSession loginsession = (LoginSession)Session["Login"]; model.ModifyBy = Convert.ToInt64(loginsession.UserID); if (BAL.PeerConsumerModel.UpdatePeerConsumerAverages(model)) { return RedirectToAction("Index", "Peer"); } else { return Content("Unable to save ,Plz Try again"); } } catch (Exception ex) { return Content("ErrorMessage" + ":" + ex.StackTrace.ToString()); } } else { return RedirectToAction("Index", "Home"); } }
public ActionResult Edit(String PeerID) { if (Session["Login"] != null) { LoginSession loginsession = (LoginSession)Session["Login"]; ViewBag.CompanyLogo = loginsession.CompanyLogo; ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType); String actionName = this.ControllerContext.RouteData.Values["action"].ToString(); String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType)); ViewBag.RoleName = loginsession.RoleName; if (PeerID != null) { String DPeerID = BAL.Security.URLDecrypt(PeerID); if ((DPeerID != "0") && (DPeerID != null)) { PeerConsumerClass peer = new PeerConsumerClass(); try { peer = BAL.PeerConsumerModel.EditPeerConsumerAverages(DPeerID); ViewBag.SID = peer.ID; ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text", peer.ClientID); ViewBag.Site = new SelectList(BAL.SiteModel.SiteDropDownList(loginsession.UserID.ToString(), peer.ClientID, loginsession.UserType.ToString(), loginsession.RoleName), "Value", "Text", peer.SiteID); } catch (Exception ex) { return Content(ex.Message); } return View(peer); } } { return RedirectToAction("Index", "Peer"); } } else { return RedirectToAction("Index", "Home"); } }