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")); }
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)); }
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")); }
public async Task <ActionResult <BrandViewModel> > AddBrandItem(BrandViewModel model) { model.UserId = _userId; var brand = await _brandService.AddBrand(model); return(Ok(brand)); }
public IActionResult BrandAdd([FromBody] Brand brand) { var result = _brandService.AddBrand(brand); if (result.Success) { return(Ok(result)); } return(BadRequest(result.Message)); }
public IActionResult BrandAdd(Brand Brand) { var result = _brandService.AddBrand(Brand); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <IActionResult> AddBrand(AddBrandDto newBrand) { ServiceResponse <Brand> response = await _brandService.AddBrand(newBrand); if (response.Data == null) { return(NotFound(response)); } return(Ok(response)); }
public Brand AddNewBrand([FromBody] Brand oBrand) { if (ModelState.IsValid) { return(_iBrandService.AddBrand(oBrand)); } else { return(null); } }
public IActionResult Add(NBrand brand) { var result = _iBrandService.AddBrand(brand); if (result.Success == true) { return(Ok(result)); } return(BadRequest(result)); }
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; } }
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")); }
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")); }
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")); }
/// <summary> /// 添加一个品牌 /// </summary> /// <param name="model"></param> public static void AddBrand(DTO.Brand model) { _brandService.AddBrand(model.Map <Model.BrandInfo>()); }
public async Task <string> AddBrand([FromBody] BrandRequest request) { return(await _brandService.AddBrand(request)); }
public async Task <IActionResult> AddBrand([FromBody] BrandDto brandDto) { return(await Create(nameof(GetAdminBrands), async() => await _brandService.AddBrand(brandDto.Name))); }