示例#1
0
        public ActionResult Edit()
        {
            int id = 0;

            if (Session["PropId"] != null)
            {
                id = Convert.ToInt32(Session["PropId"].ToString());
            }
            else
            {
                throw new Exception("Property ID Null");
            }
            etblPropertyM_User obj = new etblPropertyM_User();

            try
            {
                obj                   = BL_tblPropertyM.GetSingleRecordById_User(id);
                obj.sviewType         = "Edit";
                obj.StateList         = BL_tblStateM.StateList(obj.iStateId, obj.iCountryId);
                obj.CityList          = BL_tblCityM.CityList(obj.iCityId, obj.iStateId, obj.iCountryId);
                obj.AreaList          = BL_tblMacroAreaM.AreasList(obj.iAreaId, obj.iCityId);
                obj.LocalityList      = BL_Locality.LocalityList(obj.iLocalityId, obj.iAreaId);
                obj.AccessbilityItems = BL_tblAccessbilityM.GetAccessbilities(obj.sAccessbilityIds);
                obj.AwardsItems       = BL_tblAwardM.GetAwards(obj.sAwardIds);
                obj.AffilationItems   = BL_tblAffiliationM.GetAffilations(obj.sAffiliationIds);
                obj.LanguagesItems    = BL_tblLanguageM.GetLanguages(obj.sLanguageIds);
                //for only showing purpose
                obj.sHotelNameO  = obj.sHotelName;
                obj.iChainIdO    = obj.iChainId;
                obj.iCountryIdO  = obj.iCountryId;
                obj.iStateIdO    = obj.iStateId;
                obj.iCityIdO     = obj.iCityId;
                obj.iAreaIdO     = obj.iAreaId;
                obj.iLocalityIdO = obj.iLocalityId;

                ViewBag.PropertyLocalityMap = GetLocalitiesJson(BL_tblPropertyM.GetPropertyLocalityMap(id));
            }
            catch (Exception)
            {
                throw;
            }
            return(View(obj));
        }
示例#2
0
        public ActionResult Modify(etblPropertyM_User prop)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        prop.dtActionDate = DateTime.Now;
                        //get all AccessbilityId comma seperated
                        if (prop.SelectedAccessbility != null)
                        {
                            prop.sAccessbilityIds = prop.SelectedAccessbility.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                        }
                        //get all AwardsIds comma seperated
                        if (prop.SelectedAwards != null)
                        {
                            prop.sAwardIds = prop.SelectedAwards.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                        }
                        //get all AffilationsIds comma seperated
                        if (prop.SelectedAffilations != null)
                        {
                            prop.sAffiliationIds = prop.SelectedAffilations.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                        }
                        //get all languages comma seperated
                        if (prop.SelectedLanguages != null)
                        {
                            prop.sLanguageIds = prop.SelectedLanguages.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                        }
                        if (prop.SelectPrimaryLocalities != null)
                        {
                            JArray jArray = (JArray)JsonConvert.DeserializeObject(prop.SelectPrimaryLocalities.Replace("\\", "\""));
                            if (jArray != null)
                            {
                                List <etblPropertyLocalityMap> lstPropertyLocalityMap = new List <etblPropertyLocalityMap>();
                                foreach (var item in jArray)
                                {
                                    lstPropertyLocalityMap.Add(new etblPropertyLocalityMap()
                                    {
                                        iPropId         = prop.iPropId,
                                        iAreaLocalityId = Convert.ToInt32(item["Id"]),
                                        cAreaLocality   = Convert.ToString(item["Status"]),
                                        dtActionDate    = DateTime.Now,
                                        iActionBy       = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId
                                    });
                                }
                                prop.PropertyLocalityMapList = lstPropertyLocalityMap;
                            }
                        }
                        prop.iActionBy = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId;
                        int result = BL_tblPropertyM.UpdateRecord_User(prop);
                        if (result == 1)
                        {
                            TempData["msg"] = "Property Informaion Modified Successfully";
                            return(RedirectToAction("Edit"));
                        }
                        else
                        {
                            TempData["Error"] = "Some unknown error had happen !";
                            return(View(prop.sviewType, prop));
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }

                prop.AccessbilityItems = BL_tblAccessbilityM.GetAccessbilities(prop.sAccessbilityIds);
                prop.AwardsItems       = BL_tblAwardM.GetAwards(prop.sAwardIds);
                prop.AffilationItems   = BL_tblAffiliationM.GetAffilations(prop.sAffiliationIds);
                prop.LanguagesItems    = BL_tblLanguageM.GetLanguages(prop.sLanguageIds);
                prop.StateList         = BL_tblStateM.StateList(prop.iStateId, prop.iCountryId);
                prop.CityList          = BL_tblCityM.CityList(prop.iCityId, prop.iStateId, prop.iCountryId);
                prop.AreaList          = BL_tblMacroAreaM.AreasList(prop.iAreaId, prop.iCityId);
                prop.LocalityList      = BL_Locality.LocalityList(prop.iLocalityId, prop.iAreaId);
                //prop.sAccessbilityIds = prop.SelectedAccessbility.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                ////get all AwardsIds comma seperated
                //prop.sAwardIds = prop.SelectedAwards.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                ////get all AffilationsIds comma seperated
                //prop.sAffiliationIds = prop.SelectedAffilations.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                ////get all languages comma seperated
                //prop.sLanguageIds = prop.SelectedLanguages.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + "," + s2);
                //for only showing purpose
                prop.sHotelNameO            = prop.sHotelName;
                prop.iChainIdO              = prop.iChainId;
                prop.iCountryIdO            = prop.iCountryId;
                prop.iStateIdO              = prop.iStateId;
                prop.iCityIdO               = prop.iCityId;
                prop.iAreaIdO               = prop.iAreaId;
                prop.iLocalityIdO           = prop.iLocalityId;
                ViewBag.PropertyLocalityMap = GetLocalitiesJson(BL_tblPropertyM.GetPropertyLocalityMap(prop.iPropId));
                TempData["Error"]           = "Validation failed ! Please correct the errors and try again.";
            }
            catch (Exception)
            {
            }
            return(View(prop.sviewType, prop));
        }