/// <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); }
/// <summary> /// Maps time, finalized, receiptId, cost and managerId /// </summary> /// <param name="dto"></param> /// <returns></returns> /// <exception cref="NullReferenceException"></exception> public static ReceiptDTO FromBLL(BLLReceiptDTO dto) { if (dto == null) { throw new NullReferenceException("Can't map, BLLReceiptDTO is null"); } return(new ReceiptDTO() { CreatedTime = dto.CreatedTime, IsFinalized = dto.IsFinalized, ReceiptId = dto.ReceiptId, SumCost = dto.SumCost, ReceiptManagerId = dto.ReceiptManagerId }); }
/// <summary> /// Maps id, createdTime, finalized, sumCost, Rows() /// </summary> /// <param name="dto"></param> /// <returns></returns> /// <exception cref="NullReferenceException"></exception> public static ReceiptAllDTO FromBLLToAll(BLLReceiptDTO dto) { if (dto == null) { throw new NullReferenceException("Can't map, BLLReceiptDTO is null"); } return(new ReceiptAllDTO() { CreatedTime = dto.CreatedTime, ManagerNickname = dto.ManagerNickname, IsFinalized = dto.IsFinalized, ReceiptId = dto.ReceiptId, SumCost = dto.SumCost, Rows = dto.ReceiptRows .Select(ReceiptRowMapper.FromBLL) .ToList() }); }