Пример #1
0
        public async Task Update(Guid id, PriceList priceList)
        {
            if (id != priceList.Id)
            {
                Notify($"The supplied ids {id} and {priceList.Id} are differents.");
                return;
            }

            if (!Validate(new PriceListValidation(), priceList))
            {
                return;
            }

            var priceListToUpdate = await GetById(id);

            if (priceListToUpdate == null)
            {
                Notify($"The price list {id} not found.");
                return;
            }

            priceListToUpdate.Name   = priceList.Name;
            priceListToUpdate.Active = priceList.Active;

            _priceListRepository.Update(priceListToUpdate);

            await UnitOfWork.Save();
        }
Пример #2
0
 public async Task <IActionResult> UpdatePrice([FromBody] PriceList price)
 {
     try
     {
         return(Ok(await _repository.Update(price)));
     }
     catch (Exception exc)
     {
         _logger.LogError($"Error: {exc}");
         // transaction.Rollback();
         return(NotFound());
     }
 }
 public ActionResult Edit(EditPriceList model)
 {
     if (ModelState.IsValid)
     {
         PriceList pice = _priceListRepository.GetById(model.ID);
         pice.Title = model.Title;
         _priceListRepository.Update(pice);
         _priceListRepository.SaveChanges();
     }
     else
     {
         return(View(model));
     }
     return(RedirectToAction("GetAll"));
 }