コード例 #1
0
        public ActionResult AddNewBrand(BrandViewModel brand, HttpPostedFileBase uploadImage)
        {
            if (ModelState.IsValid)
            {
                if (uploadImage != null)
                {
                    byte[] imageData = null;
                    using (var binaryReader = new BinaryReader(uploadImage.InputStream))
                    {
                        imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
                    }
                    brand.Photo = imageData;
                }

                try
                {
                    brandService.AddBrand(Mapper.Map <BrandViewModel, BrandDTO>(brand));
                }
                catch (ValidationException ex)
                {
                    ViewBag.PropertyException = ex.Property;
                    ViewBag.MessageException  = ex.Message;

                    return(View("ExceptionView"));
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult Add(BrandModel brand)
 {
     if (ModelState.IsValid)
     {
         BrandInfo model = new BrandInfo()
         {
             Name             = brand.BrandName.Trim(),
             Description      = brand.BrandDesc,
             Logo             = brand.BrandLogo,
             Meta_Description = brand.MetaDescription,
             Meta_Keywords    = brand.MetaKeyWord,
             Meta_Title       = brand.MetaTitle,
             //RewriteName = brand.BrandEnName,
             //ShopId = 0,
             IsRecommend = brand.IsRecommend,
             //AuditStatus = BrandInfo.BrandAuditStatus.Audited
         };
         bool flag = _iBrandService.IsExistBrand(brand.BrandName);
         if (flag == false)
         {
             _iBrandService.AddBrand(model);
         }
         return(RedirectToAction("Management"));
     }
     return(View(brand));
 }
コード例 #3
0
ファイル: AdminController.cs プロジェクト: dev-dean-xu/DOMS
        public async Task <IActionResult> AddBrand(Brand brand)
        {
            ViewBag.CountryList = _countryService.GetCountries().OrderBy(x => x.CountryName);
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var files     = HttpContext.Request.Form.Files;
            var imgFolder = Path.Combine(_appEnvironment.WebRootPath, "images\\upload\\logo");

            foreach (var image in files)
            {
                try
                {
                    brand.BrandLogo = await ImageUploader.UploadImage(image, imgFolder).ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("BrandLogo", ex.Message);
                    return(View());
                }
            }

            _brandService.AddBrand(brand);

            return(RedirectToAction("Brands"));
        }
コード例 #4
0
        public async Task <ActionResult <BrandViewModel> > AddBrandItem(BrandViewModel model)
        {
            model.UserId = _userId;
            var brand = await _brandService.AddBrand(model);

            return(Ok(brand));
        }
コード例 #5
0
        public IActionResult BrandAdd([FromBody] Brand brand)
        {
            var result = _brandService.AddBrand(brand);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result.Message));
        }
コード例 #6
0
        public IActionResult BrandAdd(Brand Brand)
        {
            var result = _brandService.AddBrand(Brand);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
コード例 #7
0
        public async Task <IActionResult> AddBrand(AddBrandDto newBrand)
        {
            ServiceResponse <Brand> response = await _brandService.AddBrand(newBrand);

            if (response.Data == null)
            {
                return(NotFound(response));
            }
            return(Ok(response));
        }
コード例 #8
0
 public Brand AddNewBrand([FromBody] Brand oBrand)
 {
     if (ModelState.IsValid)
     {
         return(_iBrandService.AddBrand(oBrand));
     }
     else
     {
         return(null);
     }
 }
コード例 #9
0
        public IActionResult Add(NBrand brand)
        {
            var result = _iBrandService.AddBrand(brand);

            if (result.Success == true)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
コード例 #10
0
        public async Task <IActionResult> AddBrand([FromBody] Brand brand)
        {
            try
            {
                var data = await _brandService.AddBrand(brand);

                return(Ok(data));
            }
            catch (Exception exception)
            {
                Log.Error(exception, "Error report generate {@brand} on {AddBrand}", brand, DateTime.Now);
                throw exception;
            }
        }
コード例 #11
0
 public IActionResult Create(Brand model)
 {
     try
     {
         model.CreatedDate = DateTime.Now;
         _brandService.AddBrand(model);
         TempData["message"] = "Successfully created brand";
     }
     catch (Exception ex)
     {
         throw;
     }
     return(RedirectToAction("Index"));
 }
コード例 #12
0
        public IActionResult Create([FromForm] BrandViewModel newBrand)
        {
            if (!ModelState.IsValid)
            {
                return(View(newBrand));
            }
            var brandDto = new BrandDto
            {
                Name    = newBrand.Name,
                LogoUrl = newBrand.LogoUrl
            };

            brandService.AddBrand(brandDto);

            return(RedirectToAction("Index"));
        }
コード例 #13
0
        public ActionResult AddBrand(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                ViewBag.Message = "请输入品牌名称";

                var _list = _brandService.GetAll();
                ViewBag.List = _list;
                return(View("Index"));
            }
            _brandService.AddBrand(new Brand
            {
                BrandName = name
            });

            return(RedirectToAction("Index"));
        }
コード例 #14
0
 /// <summary>
 /// 添加一个品牌
 /// </summary>
 /// <param name="model"></param>
 public static void AddBrand(DTO.Brand model)
 {
     _brandService.AddBrand(model.Map <Model.BrandInfo>());
 }
コード例 #15
0
 public async Task <string> AddBrand([FromBody] BrandRequest request)
 {
     return(await _brandService.AddBrand(request));
 }
コード例 #16
0
 public async Task <IActionResult> AddBrand([FromBody] BrandDto brandDto)
 {
     return(await Create(nameof(GetAdminBrands), async() => await _brandService.AddBrand(brandDto.Name)));
 }