public async Task <IActionResult> PutEcategory(short id, Ecategory ecategory) { if (id != ecategory.EcategoryId) { return(BadRequest()); } _context.Entry(ecategory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EcategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Ecategory> > PostEcategory(Ecategory ecategory) { _context.Ecategory.Add(ecategory); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (EcategoryExists(ecategory.EcategoryId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetEcategory", new { id = ecategory.EcategoryId }, ecategory)); }