public async Task <IActionResult> EditBrand(int id, BrandRequest model) { DataResponse response = new DataResponse(); try { if (!ModelState.IsValid) { response.Message = string.Join("", ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage)); return(BadRequest(response)); } var brand = await _brandService.GetById(id); if (brand == null) { response.Message = "The brand is not found."; return(NotFound(response)); } await _brandService.Edit(brand, model); response.Success = 1; response.Message = "The brand has been updated."; return(Ok(response)); } catch (Exception ex) { response.Message = ex.Message; return(StatusCode(500, response)); } }
public IActionResult Editar(Data.Models.Brand brand) { if (!ModelState.IsValid) { ViewBag.Providers = _providerService.GetSelectList(); return(View(brand)); } var result = _brandService.Edit(brand); TempData.Put("Notification", result); return(RedirectToAction("Principal")); }