Exemple #1
0
        public IActionResult Delete(int id)
        {
            PriceUpdatedLog productsLog = _context.PriceUpdatedLogs.Find(id);

            if (productsLog == null)
            {
                var error = returnObject("Lod does not exist", 404, 0);
                return(NotFound(error));
            }
            _context.PriceUpdatedLogs.Remove(productsLog);
            _context.SaveChanges();
            var message = returnObject("Log deleted correctly", 200, 1);

            return(Ok(message));
        }
Exemple #2
0
 public IActionResult Post([FromBody] PriceUpdatedLog productsLog)
 {
     try
     {
         _context.Add(productsLog);
         _context.SaveChanges();
         var message = returnObject("Log added correctly", 200, 1);
         return(Ok(message));
     }
     catch (Exception ex)
     {
         string e     = ex.Message;
         var    error = returnObject(e, 400, 0);
         return(BadRequest(error));
     }
 }
Exemple #3
0
 public IActionResult Put([FromBody] PriceUpdatedLog productsLog)
 {
     try
     {
         PriceUpdatedLog _productsLog = _context.PriceUpdatedLogs.FirstOrDefault(x => x.PriceUpdatedLogId == productsLog.PriceUpdatedLogId);
         _productsLog.ProductId    = productsLog.ProductId;
         _productsLog.CurrentPrice = productsLog.CurrentPrice;
         _productsLog.NewPrice     = productsLog.NewPrice;
         _context.SaveChanges();
         var message = returnObject("log modified correctly", 200, 1);
         return(Ok(message));
     }
     catch (Exception ex)
     {
         string e     = ex.Message;
         var    error = returnObject(e, 400, 0);
         return(BadRequest(error));
     }
 }