예제 #1
0
 /// <summary>
 /// Maps ProductId, ReceiptId, Amount, Discount
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 /// <exception cref="NullReferenceException"></exception>
 public static BLLReceiptRowDTO FromAPI2(ReceiptRowMinDTO dto)
 {
     if (dto == null)
     {
         throw new NullReferenceException("Can't map, ReceiptRowMinDTO is null");
     }
     if (dto.Amount == null || dto.ProductId == null || dto.ReceiptId == null)
     {
         return(null);
     }
     return(new BLLReceiptRowDTO()
     {
         Amount = dto.Amount.Value,
         Discount = dto.Discount,
         ProductId = dto.ProductId.Value,
         ReceiptId = dto.ReceiptId.Value
     });
 }
예제 #2
0
        public async Task <ActionResult <ReceiptRowAllDTO> > AddRow(ReceiptRowMinDTO receiptRowDTO)
        {
            if (receiptRowDTO == null)
            {
                return(BadRequest("DTO missing"));
            }
            var bllDto = ReceiptRowMapper.FromAPI2(receiptRowDTO);

            if (bllDto == null)
            {
                return(BadRequest("Data missing from dto"));
            }

            var receiptRowDto = await _bll.ReceiptsService.AddRow(bllDto, User.GetUserId());

            if (receiptRowDto == null)
            {
                return(BadRequest("Something went wrong while adding"));
            }
            return(ReceiptRowMapper.FromBLL(receiptRowDto));
        }