Esempio n. 1
0
        public ActionResult Brand_add1(YG.SC.DataAccess.ShopBrand shopBrand)
        {
            DataAccess.ShopBrand moudel = new DataAccess.ShopBrand();
            moudel.CreatTime    = DateTime.Now;
            moudel.Recsts       = 1;
            moudel.Name         = shopBrand.Name;
            moudel.Abbreviation = shopBrand.Abbreviation;
            moudel.Url          = shopBrand.Url;
            moudel.Address      = shopBrand.Address;
            moudel.Rmark        = shopBrand.Rmark;
            moudel.Logo         = shopBrand.Logo;
            moudel.QRCode       = shopBrand.QRCode;
            _shopBrandService.Insert(moudel);
            Customer customer = _iCustomerService.GetEntityById(UserId);

            customer.Companyid = moudel.Id;
            customer.Id        = UserId;
            this._iCustomerService.Update(customer);
            //增加业态
            List <ShopBrandAttributeValues> listattr = new List <ShopBrandAttributeValues>();
            var attributesvalue = Request["selAttribute"].TrimEnd(',');

            if (!string.IsNullOrEmpty(attributesvalue))
            {
                foreach (var item in attributesvalue.Split(','))
                {
                    ShopBrandAttributeValues bv = new ShopBrandAttributeValues()
                    {
                        BrandId           = moudel.Id,
                        Recsts            = 1,
                        AttributesId      = Convert.ToInt32(item.Split('-')[0]),
                        AttributeValuesId = Convert.ToInt32(item.Split('-')[1]),
                    };
                    listattr.Add(bv);
                }
            }
            this._iShopAttributesServiceService.InsertList(listattr);
            ViewBag.attributesvalue = Request["selAttribute"];
            return(RedirectToAction("Brand_add2/" + moudel.Id));
        }
Esempio n. 2
0
        public ActionResult BrandEdit(Brand model)
        {
            bool     isMember;
            bool     isBrand;
            Customer member = GetCurrentUser(out isMember, out isBrand);

            if (member == null || !isMember)//只有已登录的会员用户才可以管理自己的品牌。
            {
                return(RedirectToAction("Index", "Login"));
            }
            var       fileLogoName   = UploadImgUtility.UploadImage(Request.Files["Logo"], Server.MapPath(CommonContorllers.FileUploadBrandLogoImgPath));
            var       fileQRCodeName = UploadImgUtility.UploadImage(Request.Files["QRCode"], Server.MapPath(CommonContorllers.FileUploadBrandQRCodeImgPath));
            ShopBrand sb             = new ShopBrand();

            if (isBrand)
            {
                sb = _IShopBrandService.GetById(member.Companyid);
            }
            sb.Name = model.Name;
            if (!string.IsNullOrEmpty(fileLogoName))
            {
                sb.Logo = fileLogoName;
            }
            if (!string.IsNullOrEmpty(fileQRCodeName))
            {
                sb.QRCode = fileQRCodeName;
            }
            sb.Url          = model.WebUrl;
            sb.VidoUrl      = model.VideoUrl;
            sb.JoinIn       = model.IsAllowJoin;
            sb.Recsts       = model.IsValid ? 1 : 0;
            sb.Abbreviation = model.Introduce;
            if (isBrand)
            {
                sb.Id = member.Companyid;
                _IShopBrandService.Update(sb);
            }
            else
            {
                _IShopBrandService.Insert(sb);
                Customer c = _iCustomerService.GetEntityById(UserContext.Current.Id);
                c.Companyid = sb.Id;
                _iCustomerService.Update(c);
            }
            //增加业态
            List <ShopBrandAttributeValues> listattr = new List <ShopBrandAttributeValues>();
            var attributesvalue = Request["selAttribute"];

            if (!string.IsNullOrEmpty(attributesvalue))
            {
                foreach (var item in attributesvalue.Split(','))
                {
                    ShopBrandAttributeValues bv = new ShopBrandAttributeValues()
                    {
                        BrandId           = sb.Id,
                        Recsts            = 1,
                        AttributesId      = Convert.ToInt32(item.Split('-')[0]),
                        AttributeValuesId = Convert.ToInt32(item.Split('-')[1]),
                    };
                    listattr.Add(bv);
                }
            }
            this._iShopAttributesServiceService.InsertList(listattr);
            return(RedirectToAction("Brand"));
        }