public int ChangeUserServiceArea(int areaId) { string areaName = ""; if (User.Identity.IsAuthenticated) { UserModel userModel = new UserModel(); UserInfo userInfo = userModel.GetUserInfo(User.Identity.Name); UserDefaultArea defaultArea; if (userInfo.UserDefaultArea.Count == 0) { defaultArea = new UserDefaultArea(); defaultArea.UserId = userInfo.Id; defaultArea.AreaId = areaId; userModel.Add(defaultArea); } else { defaultArea = userModel.GetUserDefaultArea(userInfo.Id); defaultArea.AreaId = areaId; userModel.Save(); } areaName = defaultArea.ServiceArea.Value; } else { BaseDataModel baseModel = new BaseDataModel(); areaName = baseModel.GetServiceArea(areaId).Value; } System.Web.HttpCookie areaCookie = new System.Web.HttpCookie("udefaultarea"); areaCookie.Domain = BaseDataModel.CookieDomain; areaCookie.Values["Id"] = areaId.ToString(); areaCookie.Values["Name"] = HttpUtility.UrlEncode(areaName); areaCookie.Expires = DateTime.Now.AddYears(1); Response.Cookies.Set(areaCookie); return 1; }