Esempio n. 1
0
        public ActionResult <HighPrice> Update([FromRoute] int id, [FromBody] decimal price)
        {
            var highPrice = HighPriceService.Update(id, price);

            if (highPrice == null)
            {
                return(NotFound());
            }
            return(Ok(highPrice));
        }
Esempio n. 2
0
        public ActionResult <HighPrice> GetById([FromRoute] int id)
        {
            var highPrice = HighPriceService.GetById(id);

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