public async Task <IActionResult> PutFirm(int id, Firm firm) { if (id != firm.Id) { return(BadRequest()); } FirmValid valid = new FirmValid(_context, firm); if (valid.Valid() == false) { return(BadRequest("Данная фирма уже существует")); } _context.Entry(firm).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FirmExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCosmetic(int id, Cosmetic cosmetic) { if (id != cosmetic.Id) { return(BadRequest()); } CosmeticValid valid = new CosmeticValid(_context, cosmetic); if (valid.Valid() == false) { return(BadRequest("Данное косметичсекое средство уже существует")); } _context.Entry(cosmetic).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CosmeticExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProductColor(int id, ProductColor productColor) { if (id != productColor.Id) { return(BadRequest()); } ProductColorValid valid = new ProductColorValid(_context, productColor); if (valid.Valid() == false) { return(BadRequest("Данное косметическое средство в этом цвете уже существует")); } _context.Entry(productColor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductColorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Put_Color(int id, _Color _Color) { if (id != _Color.Id) { return(BadRequest()); } ColorValid valid = new ColorValid(_context, _Color); if (valid.Valid() == false) { return(BadRequest("Данный цвет уже существует")); } _context.Entry(_Color).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!_ColorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutArea(int id, Area area) { if (id != area.Id) { return(BadRequest()); } AreaValid valid = new AreaValid(_context, area); if (valid.Valid() == false) { return(BadRequest("Данная область приминения уже существует")); } _context.Entry(area).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AreaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCountry(int id, Country country) { if (id != country.Id) { return(BadRequest()); } CountryValid valid = new CountryValid(_context, country); if (valid.Valid() == false) { return(BadRequest("Данная страна уже существует")); } _context.Entry(country).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }