示例#1
0
 public WholePrice(WholePriceViewModel wholePriceVm)
 {
     ProductId    = wholePriceVm.ProductId;
     FromQuantity = wholePriceVm.FromQuantity;
     ToQuantity   = wholePriceVm.ToQuantity;
     Price        = wholePriceVm.Price;
 }
        public async Task <IActionResult> Update([FromBody] WholePriceViewModel wholePriceVm)
        {
            var hasPermission = await _authorizationService.AuthorizeAsync(User, "PRODUCT", Operations.Update);

            if (hasPermission.Succeeded == false)
            {
                return(new BadRequestObjectResult(CommonConstants.Forbidden));
            }
            if (ModelState.IsValid)
            {
                try
                {
                    _wholePriceService.Update(wholePriceVm);
                    _wholePriceService.SaveChanges();
                    return(new OkObjectResult(wholePriceVm));
                }
                catch (Exception ex)
                {
                    return(new BadRequestObjectResult(ex.Message));
                }
            }
            return(new BadRequestObjectResult(ModelState));
        }
示例#3
0
 public void Update(WholePriceViewModel wholePriceVm)
 {
     _wholePriceRepository.Update(_mapper.Map <WholePrice>(wholePriceVm));
 }
示例#4
0
 public void Add(WholePriceViewModel wholePriceVm)
 {
     _wholePriceRepository.Add(_mapper.Map <WholePrice>(wholePriceVm));
 }