public ActionResult ReDisableShops(string SID) { string[] strIds = SID.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); List <int> list = new List <int>(); foreach (string id in strIds) { list.Add(int.Parse(id)); } var flag = false; IShopsService shopsService = ServiceFactory.Create <IShopsService>(); using (TransactionScope scope = TransactionScopeHelper.GetTran()) { foreach (var item in list) { var data = shopsService.GetEntity(item); data.Disabled = false; shopsService.UpdateEntity(data); } scope.Complete(); flag = true; } return(Json(new Result(flag, ResultType.Other), JsonRequestBehavior.AllowGet)); }
public ActionResult EditShops(ShopModel shopModel) { IUsersService usersService = ServiceFactory.Create <IUsersService>(); IShopsService shopsService = ServiceFactory.Create <IShopsService>(); IStoresService storesService = ServiceFactory.Create <IStoresService>(); if (string.IsNullOrWhiteSpace(shopModel.ProvinceCode) || string.IsNullOrWhiteSpace(shopModel.CityCode) || string.IsNullOrWhiteSpace(shopModel.CountyCode)) { return(Json(new Result(false, "省、市、县必填"), JsonRequestBehavior.AllowGet)); } bool flage = shopsService.Exists(t => t.ID != shopModel.ID && t.ShopName == shopModel.ShopName); if (flage) { return(Json(new Result(false, "已经存在同名商家,请修改"), JsonRequestBehavior.AllowGet)); } //判断是改变了版本 bool versionHasChange = false; bool saveSuccess = false; //用事务来更新一个商家 using (TransactionScope scope = TransactionScopeHelper.GetTran()) { //商家信息 Shops shops = shopsService.GetEntity(shopModel.ID); shops.ShopName = shopModel.ShopName; shops.Domain = shopModel.Domain; shops.DomainName = shopModel.DomainName; //如果版本改变了,则需要重置商家的菜单 if (shops.ShopVersionID != shopModel.ShopVersionID) { versionHasChange = true; } shops.ShopVersionID = shopModel.ShopVersionID; shops.DueDate = shopModel.DueDate; shops.TotalMoney = shopModel.TotalMoney; shops.Remark = shopModel.Remark; shops.Disabled = shopModel.Disabled; shops.ShopType = shopModel.ShopType; shops.SalespersonID = shopModel.SalespersonID; shops.Deposit = shopModel.Deposit; shops.FinalPayment = shopModel.FinalPayment; shops.Province = shopModel.Province; shops.ProvinceCode = shopModel.ProvinceCode; shops.City = shopModel.City; shops.CityCode = shopModel.CityCode; shops.County = shopModel.County; shops.CountyCode = shopModel.CountyCode; shops.AfterSales = shopModel.AfterSales; shops.LogoUrl = shopModel.LogoUrl; shops.AnnualFee = shopModel.AnnualFee; shops.SiteName = shopModel.SiteName; bool update1 = shopsService.UpdateEntity(shops); //商家账号 Users users = usersService.GetEntity(shops.AdminUserID); users.RealName = shopModel.RealName; users.UserName = shopModel.UserName; //如果用户修改了密码,则要重新生成密码规则 if (users.Password != shopModel.Password) { //修改账号PasswordSalt要判断是否是管理员 users.PasswordSalt = Common.TextFilter.GetPasswordSalt(UserIsAdministrator(users));// Common.TextFilter.Substring(Guid.NewGuid().ToString("N"), 10, false); string endPassword = shopModel.Password + users.PasswordSalt; users.Password = Common.SecureHelper.MD5(endPassword); } users.Idcard = shopModel.Idcard; users.Phone = shopModel.Phone; users.Disabled = shopModel.Disabled; bool update2 = usersService.UpdateEntity(users); //如果版本修改了 if (versionHasChange) { ResetShopVersion(shopModel.ID, shopModel.ShopVersionID); } scope.Complete(); saveSuccess = update1 && update2; } return(Json(new Result(saveSuccess, ResultType.Add), JsonRequestBehavior.AllowGet)); //IShopsService shopsService = ServiceFactory.Create<IShopsService>(); //bool flag = shopsService.Exists(t => t.ID != shopModel.ID && string.Equals(t.ShopName, shopModel.ShopName, StringComparison.OrdinalIgnoreCase)); //if (flag) //{ // return Json(new Result(false, "该商家已存在"), JsonRequestBehavior.AllowGet); //} //bool IsSuccess = shopsService.UpdateEntity(shopModel); //return Json(new Result(IsSuccess, ResultType.Update), JsonRequestBehavior.AllowGet); }