Ejemplo n.º 1
0
        public async Task <ArticlePriceListInResponse> EditArticlePriceListInAsync(EditArticlePriceListInRequest request)
        {
            ArticlePriceListIn existingRecord = await _articlePriceListInRespository.GetAsync(request.Id);

            if (existingRecord == null)
            {
                throw new ArgumentException($"Entity with {request.Id} is not present");
            }

            if (request.ArticleId != null)
            {
                Article existingArticle = await _articleRespository.GetAsync(request.ArticleId);

                if (existingArticle == null)
                {
                    throw new NotFoundException($"Article with {request.ArticleId} is not present");
                }
            }

            ArticlePriceListIn entity = _articlePriceListInMapper.Map(request);
            ArticlePriceListIn result = _articlePriceListInRespository.Update(entity);

            int modifiedRecords = await _articlePriceListInRespository.UnitOfWork.SaveChangesAsync();

            _logger.LogInformation(Logging.Events.Edit, Messages.NumberOfRecordAffected_modifiedRecords, modifiedRecords);
            _logger.LogInformation(Logging.Events.Edit, Messages.ChangesApplied_id, result?.Id);

            return(_articlePriceListInMapper.Map(result));
        }
Ejemplo n.º 2
0
        public ArticlePriceListIn Map(EditArticlePriceListInRequest request)
        {
            if (request == null)
            {
                return(null);
            }

            ArticlePriceListIn articlePriceListIn = new ArticlePriceListIn
            {
                Id                 = request.Id,
                ValidFrom          = request.ValidFrom,
                Validto            = request.Validto,
                ScaleUnitQty       = request.ScaleUnitQty,
                ScaleUnitType      = request.ScaleUnitType,
                UnitOrder          = request.UnitOrder,
                MinOrderQty        = request.MinOrderQty,
                IsMultipleOrderQty = request.IsMultipleOrderQty,
                ArticleId          = request.ArticleId,
            };

            return(articlePriceListIn);
        }