public IActionResult Post([FromBody] BrandCompetitor item) { if (item == null) { return(BadRequest()); } item.Id = _context.BrandCompetitors.Count() + 1; _context.BrandCompetitors.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetBrand", new { id = item.Id }, item)); }
public IActionResult Update(long id, [FromBody] BrandCompetitor item) { if (item == null || item.Id != id) { return(BadRequest()); } var competitor = _context.BrandCompetitors.FirstOrDefault(t => t.Id == id); if (competitor == null) { return(NotFound()); } competitor.BrandId = item.BrandId; competitor.CompetitorBrandId = item.CompetitorBrandId; competitor.CategoryTreeId = item.CategoryTreeId; _context.BrandCompetitors.Update(competitor); _context.SaveChanges(); return(new NoContentResult()); }