public IActionResult UpdateAuction([FromBody] UpdateAuctionModel model) { var auction = this.mainService.UpdateAuction(model); if (auction == null) { return(this.NotFound("The auction doesn't exist.")); } return(this.Ok(auction)); }
public Auction UpdateAuction(UpdateAuctionModel model) { var auction = db.Auctions.FirstOrDefault(c => c.Id == model.AuctionId); if (auction == null) { return(null); } auction.CurrentPrice = model.CurrentPrice; if (model.IsSold != null) { auction.IsActive = 0; auction.EndPrice = (decimal)model.EndPrice; } db.Update(auction); db.SaveChanges(); return(auction); }