示例#1
0
        /// <summary>
        /// Maps Id, Time, IsFinalized, Cost, ManagerId, Rows(LOTS)
        /// </summary>
        /// <param name="receipt"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        /// <exception cref="NullReferenceException"></exception>
        public static BLLReceiptDTO FromDAL2(DALReceiptDTO receipt, List <DALReceiptRowDTO> rows)
        {
            if (receipt == null)
            {
                throw new NullReferenceException("Can't map, DALReceiptDTO is null");
            }
            var cost = decimal.Zero;

            if (rows != null && rows.Any())
            {
                cost = rows.Select(dto => dto.CurrentCost ?? decimal.Zero).Sum();
            }

            var result = new BLLReceiptDTO()
            {
                ReceiptId       = receipt.ReceiptId,
                ManagerNickname = receipt.ManagerNickname,
                CreatedTime     = receipt.CreatedTime,
                IsFinalized     = receipt.IsFinalized,
                ReceiptRows     = rows
                                  .Select(ReceiptRowMapper.FromDAL)
                                  .ToList(),
                SumCost = cost
            };

            return(result);
        }
示例#2
0
        public async Task <int?> AddAsync(DALReceiptDTO receiptDTO)
        {
            var receipt     = ReceiptMapper.FromDAL(receiptDTO);
            var addedEntity = (await RepoDbSet.AddAsync(receipt)).Entity;

            if (addedEntity == null)
            {
                return(null);
            }
            EntityCreationCache.Add(addedEntity.Id, addedEntity);
            return(addedEntity.Id);
        }
示例#3
0
 /// <summary>
 /// Maps ManagerId, IsFinalized, CreatedTime
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 /// <exception cref="NullReferenceException"></exception>
 public static Receipt FromDAL(DALReceiptDTO dto)
 {
     if (dto == null)
     {
         throw new NullReferenceException("Can't map, DALReceiptDTO is null");
     }
     return(new Receipt()
     {
         CreatedTime = dto.CreatedTime,
         IsFinalized = dto.IsFinalized,
         ReceiptManagerId = dto.ReceiptManagerId
     });
 }