Exemplo n.º 1
0
        public void ApplyBrand(ShopBrandApplysInfo model)
        {
            context.ShopBrandApplysInfo.Add(model);
            context.SaveChanges();
            if (model.ApplyMode == 2)
            {
                model.Logo = MoveImages(model.Id, model.ShopId, model.Logo, "logo", 1);
            }
            string authCertificate = model.AuthCertificate;
            string empty           = string.Empty;

            if (!string.IsNullOrEmpty(authCertificate))
            {
                string[] strArrays  = authCertificate.Split(new char[] { ',' });
                int      num        = 0;
                string[] strArrays1 = strArrays;
                for (int i = 0; i < strArrays1.Length; i++)
                {
                    string str = strArrays1[i];
                    num++;
                    empty = string.Concat(empty, MoveImages(model.Id, model.ShopId, str, "auth", num), ",");
                }
            }
            if (!string.IsNullOrEmpty(empty))
            {
                char[] chrArray = new char[] { ',' };
                model.AuthCertificate = empty.TrimEnd(chrArray);
            }
            context.SaveChanges();
        }
Exemplo n.º 2
0
        public void ApplyBrand(ShopBrandApplysInfo model)
        {
            Context.ShopBrandApplysInfo.Add(model);
            Context.SaveChanges();

            //移动品牌Logo
            if (model.ApplyMode == 2)
            {
                model.Logo = MoveImages(model.Id, model.ShopId, model.Logo, "logo", 1);
            }
            //移动品牌授权证书
            var    pics    = model.AuthCertificate;
            string newpics = string.Empty;

            if (!string.IsNullOrEmpty(pics))
            {
                var arr   = pics.Split(',');
                var index = 0;
                foreach (var image in arr)
                {
                    index++;
                    newpics += MoveImages(model.Id, model.ShopId, image, "auth", index) + ",";
                }
            }
            if (!string.IsNullOrEmpty(newpics))
            {
                model.AuthCertificate = newpics.TrimEnd(',');
            }
            Context.SaveChanges();
        }
Exemplo n.º 3
0
        public void AuditBrand(long id, ShopBrandApplysInfo.BrandAuditStatus status)
        {
            ShopBrandsInfo      shopBrandsInfo;
            ShopBrandApplysInfo nullable = this.context.ShopBrandApplysInfo.FindById <ShopBrandApplysInfo>(id);

            nullable.AuditStatus = (int)status;
            if (status == ShopBrandApplysInfo.BrandAuditStatus.Audited)
            {
                if (nullable.ApplyMode != 2)
                {
                    shopBrandsInfo = new ShopBrandsInfo()
                    {
                        BrandId = nullable.BrandId.Value,
                        ShopId  = nullable.ShopId
                    };
                    this.context.ShopBrandsInfo.Add(shopBrandsInfo);
                    this.context.SaveChanges();
                }
                else
                {
                    BrandInfo brandInfo = (
                        from r in this.context.BrandInfo
                        where r.Name.ToLower() == nullable.BrandName.ToLower()
                        select r).FirstOrDefault <BrandInfo>();
                    if (brandInfo != null)
                    {
                        shopBrandsInfo = new ShopBrandsInfo()
                        {
                            BrandId = brandInfo.Id,
                            ShopId  = nullable.ShopId
                        };
                        this.context.ShopBrandsInfo.Add(shopBrandsInfo);
                        this.context.SaveChanges();
                    }
                    else
                    {
                        BrandInfo brandInfo1 = new BrandInfo()
                        {
                            Name        = nullable.BrandName.Trim(),
                            Logo        = nullable.Logo,
                            Description = nullable.Description
                        };
                        BrandInfo brandInfo2 = brandInfo1;
                        this.context.BrandInfo.Add(brandInfo2);
                        this.context.SaveChanges();
                        nullable.BrandId = new long?(brandInfo2.Id);
                        BrandInfo brand = this.GetBrand(brandInfo2.Id);
                        brand.Logo     = this.MoveImages(brand.Id, brand.Logo, 1);
                        shopBrandsInfo = new ShopBrandsInfo()
                        {
                            BrandId = brand.Id,
                            ShopId  = nullable.ShopId
                        };
                        this.context.ShopBrandsInfo.Add(shopBrandsInfo);
                        this.context.SaveChanges();
                    }
                }
            }
            this.context.SaveChanges();
        }
Exemplo n.º 4
0
        public JsonResult Apply(BrandApplyModel brand)
        {
            var shopId = CurrentSellerManager.ShopId;
            ShopBrandApplysInfo model = new ShopBrandApplysInfo();

            model.BrandId   = brand.BrandId;
            model.ApplyMode = brand.BrandMode == 1 ? (int)Himall.Model.ShopBrandApplysInfo.BrandApplyMode.Exist : (int)Himall.Model.ShopBrandApplysInfo.BrandApplyMode.New;
            if (brand.BrandMode == 1)
            {
                var m = _iBrandService.GetBrand(brand.BrandId);
                if (m == null)
                {
                    throw new Himall.Core.HimallException("品牌不存在,请刷新页面重新申请");
                }
                model.BrandName   = m.Name;
                model.Logo        = m.Logo;
                model.Description = m.Description;
            }
            else
            {
                if (brand.BrandDesc.Length > 200)
                {
                    return(Json(new Result()
                    {
                        success = false, msg = "简介过长!"
                    }));
                }
                model.BrandId     = null;
                model.BrandName   = brand.BrandName.Trim();
                model.Logo        = brand.BrandLogo;
                model.Description = brand.BrandDesc;
            }

            model.Remark          = brand.Remark;
            model.AuthCertificate = brand.BrandAuthPic;
            model.ShopId          = shopId;
            model.ApplyTime       = DateTime.Now;

            bool flag = _iBrandService.IsExistApply(shopId, model.BrandName);

            if (flag == false)
            {
                _iBrandService.ApplyBrand(model);
                return(Json(new Result()
                {
                    success = true, msg = "申请成功!"
                }));
            }
            else
            {
                return(Json(new Result()
                {
                    success = false, msg = "您已经申请了该品牌!"
                }));
            }
        }
Exemplo n.º 5
0
        public ShopBrandApplysInfo GetBrandApply(long id)
        {
            ShopBrandApplysInfo description = context.ShopBrandApplysInfo.FindById <ShopBrandApplysInfo>(id);

            if (description.ApplyMode == 1)
            {
                description.Description = description.Himall_Brands.Description;
            }
            return(description);
        }
Exemplo n.º 6
0
        public void UpdateSellerBrand(ShopBrandApplysInfo model)
        {
            ShopBrandApplysInfo brandName = context.ShopBrandApplysInfo.FindBy((ShopBrandApplysInfo a) => a.Id == model.Id && a.ShopId != 0 && a.AuditStatus == 0).FirstOrDefault();

            if (brandName == null)
            {
                throw new HimallException("该品牌已被审核或删除,不能修改!");
            }
            brandName.Logo        = MoveImages(model.Id, model.Logo, 0);
            brandName.BrandName   = model.BrandName;
            brandName.Description = model.Description;
            context.SaveChanges();
        }
Exemplo n.º 7
0
        public void UpdateSellerBrand(ShopBrandApplysInfo model)
        {
            var m = Context.ShopBrandApplysInfo.FindBy(a => a.Id == model.Id && a.ShopId != 0 && a.AuditStatus == (int)ShopBrandApplysInfo.BrandAuditStatus.UnAudit).FirstOrDefault();

            if (m == null)
            {
                throw new Himall.Core.HimallException("该品牌已被审核或删除,不能修改!");
            }
            m.Logo        = MoveImages(model.Id, model.Logo);
            m.BrandName   = model.BrandName;
            m.Description = model.Description;
            Context.SaveChanges();
        }
Exemplo n.º 8
0
        public void UpdateSellerBrand(ShopBrandApplysInfo model)
        {
            ShopBrandApplysInfo brandName = this.context.ShopBrandApplysInfo.FindBy <ShopBrandApplysInfo>((ShopBrandApplysInfo a) => a.Id == model.Id && a.ShopId != (long)0 && a.AuditStatus == 0).FirstOrDefault <ShopBrandApplysInfo>();

            if (brandName == null)
            {
                throw new TaoLaException("该品牌已被审核或删除,不能修改!");
            }
            brandName.Logo        = this.MoveImages((long)model.Id, model.Logo, 0);
            brandName.BrandName   = model.BrandName;
            brandName.Description = model.Description;
            this.context.SaveChanges();
        }
Exemplo n.º 9
0
        public JsonResult Apply(BrandApplyModel brand)
        {
            long shopId = base.CurrentSellerManager.ShopId;
            ShopBrandApplysInfo shopBrandApplysInfo = new ShopBrandApplysInfo()
            {
                BrandId   = new long?(brand.BrandId),
                ApplyMode = (brand.BrandMode == 1 ? 1 : 2)
            };

            if (brand.BrandMode != 1)
            {
                shopBrandApplysInfo.BrandId     = null;
                shopBrandApplysInfo.BrandName   = brand.BrandName.Trim();
                shopBrandApplysInfo.Logo        = brand.BrandLogo;
                shopBrandApplysInfo.Description = brand.BrandDesc;
            }
            else
            {
                BrandInfo brandInfo = ServiceHelper.Create <IBrandService>().GetBrand(brand.BrandId);
                if (brandInfo != null)
                {
                    shopBrandApplysInfo.BrandName   = brandInfo.Name;
                    shopBrandApplysInfo.Logo        = brandInfo.Logo;
                    shopBrandApplysInfo.Description = brandInfo.Description;
                }
            }
            shopBrandApplysInfo.Remark          = brand.Remark;
            shopBrandApplysInfo.AuthCertificate = brand.BrandAuthPic;
            shopBrandApplysInfo.ShopId          = shopId;
            shopBrandApplysInfo.ApplyTime       = DateTime.Now;
            if (ServiceHelper.Create <IBrandService>().IsExistApply(shopId, shopBrandApplysInfo.BrandName))
            {
                Result result = new Result()
                {
                    success = false,
                    msg     = "您已经申请了该品牌!"
                };
                return(Json(result));
            }
            ServiceHelper.Create <IBrandService>().ApplyBrand(shopBrandApplysInfo);
            Result result1 = new Result()
            {
                success = true,
                msg     = "申请成功!"
            };

            return(Json(result1));
        }
Exemplo n.º 10
0
        public void UpdateBrand(BrandInfo model)
        {
            model.Logo = MoveImages(model.Id, model.Logo, 0);
            BrandInfo brand = GetBrand(model.Id);

            brand.Name             = model.Name.Trim();
            brand.Description      = model.Description;
            brand.Logo             = model.Logo;
            brand.Meta_Description = model.Meta_Description;
            brand.Meta_Keywords    = model.Meta_Keywords;
            brand.Meta_Title       = model.Meta_Title;
            brand.RewriteName      = model.RewriteName;
            brand.IsRecommend      = model.IsRecommend;
            ShopBrandApplysInfo name = context.ShopBrandApplysInfo.FirstOrDefault((ShopBrandApplysInfo p) => p.BrandId == model.Id);

            name.BrandName   = model.Name;
            name.Description = model.Description;
            name.Logo        = model.Logo;
            context.SaveChanges();
        }
Exemplo n.º 11
0
        public void DeleteApply(int id)
        {
            ShopBrandApplysInfo shopBrandApplysInfo = context.ShopBrandApplysInfo.FindById <ShopBrandApplysInfo>(id);

            context.ShopBrandApplysInfo.Remove(shopBrandApplysInfo);
            if (shopBrandApplysInfo.ApplyMode == 2)
            {
                string mapPath = IOHelper.GetMapPath(shopBrandApplysInfo.Logo);
                if (File.Exists(mapPath))
                {
                    File.Delete(mapPath);
                }
            }
            string str = IOHelper.GetMapPath(shopBrandApplysInfo.AuthCertificate);

            if (File.Exists(str))
            {
                File.Delete(str);
            }
            context.SaveChanges();
        }
Exemplo n.º 12
0
        public void UpdateBrand(Model.BrandInfo model)
        {
            model.Logo = MoveImages(model.Id, model.Logo);
            BrandInfo brand = GetBrand(model.Id);

            brand.Name             = model.Name.Trim();
            brand.Description      = model.Description;
            brand.Logo             = model.Logo;
            brand.Meta_Description = model.Meta_Description;
            brand.Meta_Keywords    = model.Meta_Keywords;
            brand.Meta_Title       = model.Meta_Title;
            brand.RewriteName      = model.RewriteName;
            brand.IsRecommend      = model.IsRecommend;

            ShopBrandApplysInfo info = Context.ShopBrandApplysInfo.FirstOrDefault(p => p.BrandId == model.Id);

            if (info != null)
            {
                info.BrandName   = model.Name;
                info.Description = model.Description;
                info.Logo        = model.Logo;
            }
            Context.SaveChanges();
        }