public IActionResult Delete(long id) { var salesPoint = _context.SalesPoints.FirstOrDefault(t => t.Id == id); if (salesPoint == null) { return NotFound(); } _context.SalesPoints.Remove(salesPoint); _context.SaveChanges(); return new NoContentResult(); }
public IActionResult Post([FromBody] Partner item) { if (item == null) { return(BadRequest()); } item.Id = _context.Partners.Count() + 1; _context.Partners.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetPartner", new { id = item.Id }, item)); }
public IActionResult Post([FromBody] PurchasingDecisionModel item) { if (item == null) { return(BadRequest()); } item.Id = _context.PurchasingDecisionModels.Count() + 1; _context.PurchasingDecisionModels.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetPurchasingDecisionModel", new { id = item.Id }, item)); }
public IActionResult Post([FromBody] SocialNetwork item) { if (item == null) { return(BadRequest()); } item.Id = _context.SocialNetworks.Count() + 1; _context.SocialNetworks.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetSocialNetwork", new { id = item.Id }, item)); }
public IActionResult Post([FromBody] SalesPointPhoto item) { if (item == null) { return(BadRequest()); } item.Id = _context.SalesPointPhotos.Count() + 1; _context.SalesPointPhotos.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetSalesPointPhoto", new { id = item.Id }, item)); }
public PartnersController(PartnersContext context) { db = context; //Если БД пуста, то заполнить тестовыми данными if (!db.Partners.Any()) { db.Partners.Add(new Partner { Name = "Alpha", Type = Enums.PartnerType.LegalEntity, INN = "6465154", KPP = "4816151" }); db.Partners.Add(new Partner { Name = "Beta", Type = Enums.PartnerType.IP, INN = "4686816", KPP = "04108606" }); db.Partners.Add(new Partner { Name = "Gamma", Type = Enums.PartnerType.IP, INN = "0555457", KPP = "045734" }); db.SaveChanges(); } }