public async Task <IActionResult> Put([FromRoute] int id, [FromForm] int quantity) { var brand = await brandRepository.FindAsync(id); if (brand == null) { return(NotFound()); } var brandQuantityTimeReceived = new BrandQuantityTimeReceived { Brand = brand, Quantity = quantity, TimeReseived = DateTime.Now }; brandQuantityTimeReceivedRepository.Add(brandQuantityTimeReceived); if (await brandRepository.SaveAsync() == 0) { return(BadRequest()); } return(NoContent()); }
public async Task <IActionResult> Post([FromForm] int quantity, [FromForm] string name) { var brand = new Brand { Name = name, }; var brandQuantityTimeReceived = new BrandQuantityTimeReceived { Brand = brand, Quantity = quantity, TimeReseived = DateTime.Now }; brandRepository.Add(brand); brandQuantityTimeReceivedRepository.Add(brandQuantityTimeReceived); if (await brandRepository.SaveAsync() == 0) { return(BadRequest()); } return(CreatedAtAction("Post", brand)); }