Esempio n. 1
0
        public Object EditRecord(Int64 LevelID)
        {
            PropertyLevelMaster _Level = new PropertyLevelMaster();
            try
            {
                PropertyLevel level = DAL.DALPropertyLevel.EditPropertyLevel(Convert.ToInt32(LevelID));
                _Level.ID = level.ID;
                        if (!String.IsNullOrEmpty(level.LevelName))
                        {
                            _Level.LevelName= level.LevelName;
                        }

                        if (level.ClientID != null)
                        {
                            _Level.ClientID = level.ClientID;
                        }
                        if (level.SiteID != null)
                        {
                            _Level.SiteID = level.SiteID;
                        }

            }
            catch (Exception ex)
            {
                throw;
            }
            return _Level;
        }
 public ActionResult Create(PropertyLevelMaster model)
 {
     if (Session["Login"] != null)
     {
         if (String.IsNullOrEmpty(model.LevelName))
         {
             ModelState.AddModelError("Property Level", "Please Enter Property Level");
         }
         if (ModelState.IsValid)
         {
             try
             {
                 LoginSession loginsession = (LoginSession)Session["Login"];
                 model.CreateBy = Convert.ToInt64(loginsession.UserID);
                 if (PropertyLevelModel.CreatePropertyLevel(model))
                 {
                     return Json(new { result = 1, message = "Record was successfully Saved!" });
                 }
                 else
                 {
                     return Json(new { result = 0, message = "Duplicate Record " });
                 }
             }
             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 ActionResult Edit(String Level_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, actionName, BAL.Common.LayoutType(loginsession.UserType));
                ViewBag.RoleName = loginsession.RoleName;
                if (Level_ID != null)
                {
                    String Dec_LevelID = BAL.Security.URLDecrypt(Level_ID);
                    if ((Dec_LevelID != "0") && (Dec_LevelID != null))
                    {
                        PropertyLevelMaster level = new PropertyLevelMaster();
                        try
                        {
                            level = BAL.PropertyLevelModel.EditPropertyLevel(Dec_LevelID);
                            ViewBag.Level_ID = level.ID;

                            if (loginsession.ClientID != null)
                            {
                                if (level.ClientID != null)
                                {
                                    ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text", level.ClientID);
                                    ViewBag.ClientSelectID = level.ClientID;
                                }

                                if (level.SiteID != null)
                                {
                                    ViewBag.SiteSelectID = level.SiteID;
                                    ViewBag.Site = new SelectList(BAL.SiteModel.SiteDropDownList(loginsession.UserID.ToString(), Convert.ToInt64(level.ClientID), loginsession.UserType, loginsession.RoleName), "Value", "Text", level.SiteID);

                                }

                            }

                            else
                            {
                                if (level.ClientID != null)
                                {
                                    ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text", level.ClientID);
                                    ViewBag.ClientSelectID = level.ClientID;
                                }
                                if (level.SiteID != null)
                                {
                                    ViewBag.SiteSelectID = level.SiteID;
                                    ViewBag.Site = new SelectList(BAL.SiteModel.SiteDropDownList(loginsession.UserID.ToString(), Convert.ToInt64(level.ClientID), loginsession.UserType, loginsession.RoleName), "Value", "Text", level.SiteID);

                                }
                            }//else

                        }
                        catch (Exception ex)
                        { return Content(ex.Message); }
                        return View(level);
                    }
                }
                {
                    return RedirectToAction("Index", "PropertyLevel");
                }
            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
 public ActionResult Update(PropertyLevelMaster model)
 {
     if (Session["Login"] != null)
     {
         if (ModelState.IsValid)
         {
             try
             {
                 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;
                 model.modifyBy = Convert.ToInt64(loginsession.UserID);
                 if (PropertyLevelModel.UpdatePropertyLevel(model))
                 {
                     return RedirectToAction("Index", "PropertyLevel");
                 }
                 else
                 {
                     // return Json(new { result = 0, message = "Duplicate Currency Name " });
                     return Content("Duplicate Record, 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"); }
 }
Esempio n. 5
0
 public static bool UpdatePropertyLevel(PropertyLevelMaster Level)
 {
     Boolean flag = false;
     try
     {
         Icontext objinter = new BALPropertyLevel();
         flag = objinter.UpdateRecord(Level);
     }
     catch (Exception ex)
     {
         throw;
     }
     return flag;
 }