Ejemplo n.º 1
0
        public ActionResult <LowPrice> Update([FromRoute] int id, [FromBody] decimal price)
        {
            var lowPrice = LowPriceService.Update(id, price);

            if (lowPrice == null)
            {
                return(NotFound());
            }
            return(Ok(lowPrice));
        }
Ejemplo n.º 2
0
        public ActionResult <LowPrice> GetById([FromRoute] int id)
        {
            var lowPrice = LowPriceService.GetById(id);

            if (lowPrice == null)
            {
                return(NotFound());
            }
            return(Ok(lowPrice));
        }
Ejemplo n.º 3
0
 public ActionResult Delete(int id)
 {
     try
     {
         LowPriceService.Delete(id);
         return(Ok());
     }
     catch (EntityDoesNotExistException exception)
     {
         Logger.LogWarning(exception, exception.Message);
         return(NotFound());
     }
 }
Ejemplo n.º 4
0
 public ActionResult <LowPrice> Create([FromBody] LowPrice lowPrice)
 {
     lowPrice = LowPriceService.Create(lowPrice);
     return(CreatedAtAction(nameof(GetById), new { id = lowPrice.Id }, lowPrice));
 }
Ejemplo n.º 5
0
 /// <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;
 }