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