public ActionResult Create(PropertyBandMaster model)
        {
            if (Session["Login"] != null)
            {

                if (String.IsNullOrEmpty(model.PropertyBand))
                {
                    ModelState.AddModelError("Property Band", "Please Enter Property Band");
                }
                if (model.ClientID == null)
                {
                    ModelState.AddModelError("Client Name", "Please Enter Client Name");
                }
                if (model.SiteID== null)
                {
                    ModelState.AddModelError("Site Name", "Please Enter Site Name");
                }

                if (ModelState.IsValid)
                {
                    try
                    {
                        LoginSession loginsession = (LoginSession)Session["Login"];
                        model.CreateBy = Convert.ToInt64(loginsession.UserID);
                        if (PropertyBandModel.CreatePropertyBand(model))
                        {
                            return Json(new { result = 1, message = "Record was successfully Saved!" });
                        }
                        else
                        {
                            return Json(new { result = 0, message = "Duplicate Property Band 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();
                        }
                    }
                    return Json(new { result = 0, message = "ErrorMessage" + ":" + exception });
                }
            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
        public ActionResult Update(PropertyBandMaster model)
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];

                if (loginsession.ClientID != null)
                {
                    ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text");
                    ViewBag.Site = new SelectList(BAL.Common.Default_DDR(), "Value", "Text");

                }
                else {

                    ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text" );
                    ViewBag.Site = new SelectList(BAL.Common.Default_DDR(), "Value", "Text");
                }

                if (ModelState.IsValid)
                {
                    try
                    {

                        model.modifyBy = Convert.ToInt64(loginsession.UserID);
                        if (PropertyBandModel.UpdatePropertyBand(model))
                        {
                            return RedirectToAction("Index", "PropertyBand");
                        }
                        else
                        {
                            // return Json(new { result = 0, message = "Duplicate Currency Name " });
                            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 BandID)
        {
            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 (BandID != null)
                {
                    String Dec_BandID = BAL.Security.URLDecrypt(BandID);
                    if ((Dec_BandID != "0") && (Dec_BandID != null))
                    {
                        PropertyBandMaster band = new PropertyBandMaster();
                        try
                        {
                            band = BAL.PropertyBandModel.EditPropertyBand(Dec_BandID);
                            ViewBag.BandID = band.ID;
                                if ((band.TypeID != null)&&(band.ClientID != null)&&(band.SiteID != null))
                                {
                                    ViewBag.PropType = new SelectList(BAL.PropertyTypeModel.PropertyTypeDropDownList(band.ClientID.ToString(), band.SiteID.ToString()), "Value", "Text", band.TypeID);
                                }
                                else if ((band.ClientID != null) && (band.SiteID != null))
                                {
                                    ViewBag.PropType = new SelectList(BAL.PropertyTypeModel.PropertyTypeDropDownList(band.ClientID.ToString(), band.SiteID.ToString()), "Value", "Text");

                                }
                                else
                                {
                                    ViewBag.PropType = new SelectList(BAL.Common.Default_DDR(), "Value", "Text");
                                }
                            //-----------------------//
                                if ((band.OwnershipID != null) && (band.ClientID != null) && (band.SiteID != null))
                                {
                                    ViewBag.Ownership = new SelectList(BAL.PropertyOwnerShipModel.PropertyOwnerShipTypeDropDownList(band.ClientID.ToString(), band.SiteID.ToString()), "Value", "Text", band.OwnershipID);
                                }
                                else if ((band.ClientID != null) && (band.SiteID != null))
                                {
                                    ViewBag.Ownership = new SelectList(BAL.PropertyOwnerShipModel.PropertyOwnerShipTypeDropDownList(band.ClientID.ToString(), band.SiteID.ToString()), "Value", "Text");
                                }

                                else
                                {
                                    ViewBag.Ownership = new SelectList(BAL.Common.Default_DDR(), "Value", "Text");
                                }
                            //-------------------------------//

                                if ((band.SizeID != null) && (band.ClientID != null) && (band.SiteID != null))
                                {
                                    ViewBag.PropSize = new SelectList(BAL.PropertySizeModel.PropertySizeDropDownList(band.ClientID.ToString(), band.SiteID.ToString()), "Value", "Text", band.SizeID);
                                }
                                else if ((band.ClientID != null) && (band.SiteID != null))
                                {
                                    ViewBag.PropSize = new SelectList(BAL.PropertySizeModel.PropertySizeDropDownList(band.ClientID.ToString(), band.SiteID.ToString()), "Value", "Text");
                                }

                                else
                                {
                                    ViewBag.PropSize = new SelectList(BAL.Common.Default_DDR(), "Value", "Text");
                                }
                            //---------------------//

                                if ((band.LevelID != null) && (band.ClientID != null) && (band.SiteID != null))
                                {
                                    ViewBag.PropLevel = new SelectList(BAL.PropertyLevelModel.PropertyLevelDropDownList(band.ClientID.ToString(), band.SiteID.ToString()), "Value", "Text", band.LevelID);
                                }
                                else if ((band.ClientID != null) && (band.SiteID != null))
                                {
                                    ViewBag.PropLevel = new SelectList(BAL.PropertyLevelModel.PropertyLevelDropDownList(band.ClientID.ToString(), band.SiteID.ToString()), "Value", "Text");
                                }

                                else
                                {
                                    ViewBag.PropLevel = new SelectList(BAL.Common.Default_DDR(), "Value", "Text");
                                }

                            //----------------------------//

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

                                   }

                                }

                                else
                                {
                                     if (band.ClientID != null)
                                    {
                                    ViewBag.Client = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text", band.ClientID);
                                    ViewBag.ClientSelectID = band.ClientID;
                                     }
                                     if (band.SiteID != null)
                                     {
                                         ViewBag.SiteSelectID = band.SiteID;
                                         ViewBag.Site = new SelectList(BAL.Common.Default_DDR(), "Value", "Text");

                                     }
                                     else
                                     {
                                         ViewBag.SiteSelectID = "";
                                         ViewBag.Site = new SelectList(BAL.Common.Default_DDR(), "Value", "Text");
                                     }

                                }//
                        }
                        catch (Exception ex)
                        { return Content(ex.Message); }
                        return View(band);
                    }
                }
                {
                    return RedirectToAction("Index", "PropertyBand");
                }
            }
            else
            { return RedirectToAction("Index", "Home"); }
        }