public ActionResult <HighPrice> Update([FromRoute] int id, [FromBody] decimal price) { var highPrice = HighPriceService.Update(id, price); if (highPrice == null) { return(NotFound()); } return(Ok(highPrice)); }
public ActionResult <HighPrice> GetById([FromRoute] int id) { var highPrice = HighPriceService.GetById(id); if (highPrice == null) { return(NotFound()); } return(Ok(highPrice)); }
public ActionResult Delete(int id) { try { HighPriceService.Delete(id); return(Ok()); } catch (EntityDoesNotExistException exception) { Logger.LogWarning(exception, exception.Message); return(NotFound()); } }
public ActionResult <HighPrice> Create([FromBody] HighPrice highPrice) { highPrice = HighPriceService.Create(highPrice); return(CreatedAtAction(nameof(GetById), new { id = highPrice.Id }, highPrice)); }
/// <summary> /// Constructor method injects HighPriceService and Logger into the class upon instantiation. /// </summary> /// <param name="highPriceService">HighPriceService class Dependency Injection.</param> /// <param name="logger">Logger Dependency Injection.</param> public HighPriceController(HighPriceService highPriceService, ILogger <HighPriceController> logger) { HighPriceService = highPriceService; Logger = logger; }