public ActionResult Create() { 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; ReadFrequencyMaster Frequency = new ReadFrequencyMaster(); Frequency.Notifiy = BAL.Common.GetnotificationMode(); if (loginsession.ClientID != null) { ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text"); } else { ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text"); } ViewBag.DayOfMonthList = new SelectList(BAL.Common.GetMonthDay(), "Value", "Text"); ViewBag.NoticationDay = new SelectList(BAL.Common.WeekdaysDropDownList(), "Value", "Text"); return View(Frequency); } else { return RedirectToAction("Index", "Home"); } }
public ActionResult Create(ReadFrequencyMaster 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, BAL.Common.LayoutType(loginsession.UserType)); ViewBag.RoleName = loginsession.RoleName; if (String.IsNullOrEmpty(model.FrequencyName)) { ModelState.AddModelError("Frequency Name", "Please Enter Frequency Name"); } if (String.IsNullOrEmpty(model.SelectFrequencyMode.ToString().Trim())) { ModelState.AddModelError("Frequency Mode", "You did not select any Frequency Mode"); } if (ModelState.IsValid) { try { model.SelectFrequencyMode = model.SelectFrequencyMode.ToString().Trim(); model.CreateBy = Convert.ToInt64(loginsession.UserID); if (ReadFrequencyModel.CreateReadingFrequency(model)) { return Json(new { result = 1, message = "Record was successfully Saved!" }); } else { return Json(new { result = 0, message = "Duplicate Notification Name " }); } } 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(); } } //------------------------------------ if (loginsession.ClientID != null) { ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text"); } else { ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text"); } ViewBag.DayOfMonthList = new SelectList(BAL.Common.GetMonthDay(), "Value", "Text"); ViewBag.NoticationDay = new SelectList(BAL.Common.WeekdaysDropDownList(), "Value", "Text"); //------------------------------ return Json(new { result = 0, message = "ErrorMessage" + ":" + exception }); } } else { return RedirectToAction("Index", "Home"); } }
public ActionResult Update(ReadFrequencyMaster model) { if (Session["Login"] != null) { if (String.IsNullOrEmpty(model.SelectFrequencyMode.ToString().Trim())) { ModelState.AddModelError("Frequency Mode", "You did not select any Frequency Mode"); } if (ModelState.IsValid) { try { LoginSession loginsession = (LoginSession)Session["Login"]; model.SelectFrequencyMode = model.SelectFrequencyMode.ToString().Trim(); model.modifyBy = Convert.ToInt64(loginsession.UserID); if (BAL.ReadFrequencyModel.UpdateReadingFrequency(model)) { return RedirectToAction("Index", "ReadingFrequency"); } else { return Content("Unable to save , try again"); } } catch (Exception ex) { return Content("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 Content("ErrorMessage" + ":" + exception); } } else { return RedirectToAction("Index", "Home"); } }
public ActionResult Edit(String ID) { 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, BAL.Common.LayoutType(loginsession.UserType)); ViewBag.RoleName = loginsession.RoleName; if (ID != null) { String DecID = BAL.Security.URLDecrypt(ID); if ((DecID != "0") && (DecID != null)) { ReadFrequencyMaster Frequency = new ReadFrequencyMaster(); try { Frequency = BAL.ReadFrequencyModel.EditReadingFrequency(DecID); ViewBag.FrequencyID = Frequency.ID; List<BAL.Notification> list = BAL.Common.GetnotificationMode(); if (Frequency.SelectFrequencyMode != null) { foreach (var item in list.Where(w => w.ID == Frequency.SelectFrequencyMode)) { item.IsSelect = true; } } Frequency.Notifiy = list; if (Frequency.Weeklyday != null) { ViewBag.NoticationDayList = new SelectList(BAL.Common.WeekdaysDropDownList(), "Value", "Text", Frequency.Weeklyday); } else { ViewBag.NoticationDayList = new SelectList(BAL.Common.WeekdaysDropDownList(), "Value", "Text"); } if ((Frequency.DayOfMonth != null) && (!String.IsNullOrEmpty(Frequency.DayOfMonth))) { ViewBag.DayOfMonthList = new SelectList(BAL.Common.GetMonthDay(), "Value", "Text", Frequency.DayOfMonth); } else { ViewBag.DayOfMonthList = new SelectList(BAL.Common.GetMonthDay(), "Value", "Text"); } if (Frequency.ClientID != null) { ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text", Frequency.ClientID); } else { ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text"); } if ((Frequency.SiteID != null) && (Frequency.ClientID != null)) { ViewBag.Site = new SelectList(BAL.SiteModel.SiteDropDownList(loginsession.UserID.ToString(), Convert.ToInt64(Frequency.ClientID), loginsession.UserType.ToString(), loginsession.RoleName), "Value", "Text", Frequency.SiteID); } else { ViewBag.Site = new SelectList(BAL.SiteModel.SiteDropDownList(loginsession.UserID.ToString(), Convert.ToInt64(Frequency.ClientID), loginsession.UserType.ToString(), loginsession.RoleName), "Value", "Text"); } } catch (Exception ex) { return Content(ex.Message); } return View(Frequency); } } { return RedirectToAction("Index", "ReadingFrequency"); } } else { return RedirectToAction("Index", "Home"); } }
public Object EditRecord(Int64 FrequenceID) { ReadFrequencyMaster _Frequence = new ReadFrequencyMaster(); try { ReadFrequency Frequence = DAL.DALReadFrequency.EditReadFrequency(Convert.ToInt32(FrequenceID)); _Frequence.ID = Frequence.ID; if (Frequence.ClientID != null) { _Frequence.ClientID = Frequence.ClientID; } if (Frequence.SiteID != null) { _Frequence.SiteID = Frequence.SiteID; } if (Frequence.FrequencyName != null) { _Frequence.FrequencyName = Frequence.FrequencyName.Trim(); } if (Frequence.FrequencyMode!= null) { _Frequence.SelectFrequencyMode = Frequence.FrequencyMode.ToString(); } if (Frequence.FrequencyDay != null) { _Frequence.Weeklyday = Frequence.FrequencyDay.ToString(); } if (Frequence.DayOfMonth != null) { _Frequence.DayOfMonth = Frequence.DayOfMonth.ToString(); } } catch (Exception ex) { throw; } return _Frequence; }
public static bool UpdateReadingFrequency(ReadFrequencyMaster Frequency) { Boolean flag = false; try { Icontext objinter = new BALReadFrequency(); flag = objinter.UpdateRecord(Frequency); } catch (Exception ex) { throw; } return flag; }