public async Task <IActionResult> Create([Bind("Name")] BrandVM brand) { if (ModelState.IsValid) { await service.AddBrandAsync(brand.Adapt <BrandDTO>()); return(RedirectToAction(nameof(Index))); } return(View(brand)); }
public async Task <IActionResult> Add(AddBrandViewModel brandModel) { //TODO: make brand add friendly error page if (!ModelState.IsValid) { this.TempData.AddFailureMessage(string.Format(FailureAddItemMessage, brandModel.Name)); return(this.RedirectToAction(nameof(Index))); //return this.BadRequest(); } await brandService.AddBrandAsync(brandModel.Name); this.TempData.AddSuccessMessage(string.Format(SuccessAddItemMessage, brandModel.Name)); return(this.RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create(BrandViewsModels brand) { if (ModelState.IsValid) { var addBrand = await _brandService.AddBrandAsync(brand); if (addBrand) { TempData["Successfuly"] = _localizer.GetLocalizedString("msg_AddSuccessfuly").ToString(); return(RedirectToAction("Index")); } TempData["EditFailure"] = _localizer.GetLocalizedString("err_AddFailure").ToString(); return(View(brand)); } return(View(brand)); }
public async Task <IActionResult> PostAsync([FromForm] BrandViewModel model) { string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var addBrand = await _brandService.AddBrandAsync(model.Name, userId); if (addBrand != null) { return(Ok(new OperationResponse <Brand> { IsSuccess = true, Message = $"{addBrand.Name} has been added successfully!", Record = addBrand })); } return(BadRequest(new OperationResponse <Brand> { Message = "Something went wrong", IsSuccess = true })); }
public async Task <IActionResult> AddBrand(BrandDto model) { if (!ModelState.IsValid) { return(BadRequest("Something want wrong while adding brand")); } var brand = new Brand { Name = model.Name }; await _brandService.AddBrandAsync(brand); await _genericRepository.SaveChangesAsync(); return(Ok(new { status = 200, message = "Brand Added successfully!" })); }
public async Task <IActionResult> Post([FromBody] BrandRequestObject brandRequestObject) { var res = await _brandService.AddBrandAsync(brandRequestObject); return(res == null?CreatedAtRoute("GetBrand", new { id = res.Id }, res) : (IActionResult)BadRequest("Unable to create Brand at this time.")); }
protected override async Task <Brand> PerformAddAsync(Brand entity) { return(await _brandService.AddBrandAsync(entity)); }