public async Task <ActionResult <brandDTO> > CreateProduct(brandDTO b2) { var b1 = b2.toBrand(); _context.brands.Add(b1); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetBrand), new { id = b1.id }, b1)); }
public async Task <IActionResult> UpdateBrand(brandDTO b2) { var b1 = await _context.brands.FindAsync(b2.id); if (b1 == null) { return(NotFound()); } b1.Mapto5(b2); _context.brands.Update(b1); try{ await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) when(!BrandExist(b1.id)) { return(NotFound()); } return(NoContent()); }