示例#1
0
        /// <summary>
        /// 更新门店信息、管理员密码
        /// </summary>
        /// <param name="shopBranch"></param>
        public static void UpdateShopBranch(ShopBranch shopBranch)
        {
            if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName))
            {
                throw new MallException("门店名称不能重复!");
            }

            //AutoMapper.Mapper.CreateMap<ShopBranch, ShopBranchInfo>();
            //var shopBranchInfo = AutoMapper.Mapper.Map<ShopBranch, ShopBranchInfo>(shopBranch);

            var shopBranchInfo = shopBranch.Map <ShopBranchInfo>();


            shopBranchInfo.AddressPath = RegionApplication.GetRegionPath(shopBranchInfo.AddressId);
            //默认在结尾增加分隔符
            shopBranchInfo.AddressPath = shopBranchInfo.AddressPath + CommonConst.ADDRESS_PATH_SPLIT;
            Service.UpdateShopBranch(shopBranchInfo);

            if (!string.IsNullOrEmpty(shopBranch.PasswordOne))
            {
                if (shopBranch.PasswordOne != shopBranch.PasswordTwo)
                {
                    throw new MessageException("两次密码输入不一致");
                }
                //设置门店管理密码
                SetShopBranchManagerPassword(shopBranchInfo.Id, shopBranch.PasswordOne);
            }
        }
示例#2
0
        /// <summary>
        /// 新增门店
        /// </summary>
        public static void AddShopBranch(ShopBranch shopBranch, out long shopBranchId)
        {
            if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName))
            {
                throw new MallException("此门店名称已存在,请设置其他名称!");
            }
            var branchManangerInfo = Service.GetShopBranchManagersByName(shopBranch.UserName);

            if (branchManangerInfo != null)
            {
                throw new MallException("此门店管理员账号已存在,请设置其他名称!");
            }
            if (ManagerApplication.CheckUserNameExist(shopBranch.UserName))
            {
                throw new MallException("此门店管理员账号已存在,请设置其他名称!");
            }
            // AutoMapper.Mapper.CreateMap<ShopBranch, Entities.ShopBranchInfo>();
            //  var shopBranchInfo = AutoMapper.Mapper.Map<ShopBranch, Entities.ShopBranchInfo>(shopBranch);

            var shopBranchInfo = shopBranch.Map <Entities.ShopBranchInfo>();

            shopBranchInfo.AddressPath = RegionApplication.GetRegionPath(shopBranchInfo.AddressId);
            //默认在结尾增加分隔符
            shopBranchInfo.AddressPath = shopBranchInfo.AddressPath + CommonConst.ADDRESS_PATH_SPLIT;
            Service.AddShopBranch(shopBranchInfo);
            shopBranchId = shopBranchInfo.Id;
            var salt = GetSalt();
            var shopBranchManagerInfo = new Entities.ShopBranchManagerInfo
            {
                CreateDate   = DateTime.Now,
                UserName     = shopBranch.UserName,
                ShopBranchId = shopBranchInfo.Id,
                PasswordSalt = salt,
                Password     = GetPasswrodEncode(shopBranch.PasswordOne, salt)
            };

            Service.AddShopBranchManagers(shopBranchManagerInfo);
            shopBranch.Id = shopBranchInfo.Id;
        }