/// <summary> /// Maps Id, ReceiptId, Amount, Discount, Cost, /// Product(Id, Price, Name, Description, OrganizationId), /// Changes(id, name, price, orgId), /// Participants(Maps LoanId, ReceiptRowId, LoanRowId, Involvement, Name) /// </summary> /// <param name="dto"></param> /// <returns></returns> /// <exception cref="NullReferenceException"></exception> public static BLLReceiptRowDTO FromDAL(DALReceiptRowDTO dto) { if (dto == null) { throw new NullReferenceException("Can't map, DALReceiptRowDTO is null"); } var result = new BLLReceiptRowDTO { ReceiptId = dto.ReceiptId, Product = ProductMapper.FromDAL2(dto.Product), Amount = dto.Amount, Discount = dto.Discount, CurrentCost = dto.CurrentCost, ReceiptRowId = dto.ReceiptRowId, Changes = new List <BLLChangeDTO>(), Participants = new List <BLLRowParticipantDTO>() }; foreach (var changeDto in dto.Changes) { result.Changes.Add(ChangeMapper.FromDAL2(changeDto)); } foreach (var participantDTO in dto.Participants) { result.Participants.Add(RowParticipantMapper.FromDAL(participantDTO)); } return(result); }
/// <summary> /// Adds row /// </summary> /// <param name="row"></param> /// <param name="userId"></param> /// <returns>receiptRowId</returns> public async Task <int?> AddAsync(DALReceiptRowDTO row) { var receiptRow = ReceiptRowMapper.FromDAL(row); if (receiptRow == null) { return(null); } var receiptEntity = (await RepoDbSet.AddAsync(receiptRow)).Entity; EntityCreationCache.Add(receiptEntity.Id, receiptEntity); return(receiptEntity.Id); }
/// <summary> /// Maps Amount, ProductId, RowDiscount, ReceiptId /// </summary> /// <param name="dto"></param> /// <returns></returns> public static ReceiptRow FromDAL(DALReceiptRowDTO dto) { if (dto == null) { throw new NullReferenceException("Can't map, DALReceiptRowDTO is null"); } if (dto.Amount == null || dto.ProductId == null || dto.ReceiptId == null) { return(null); } return(new ReceiptRow() { Amount = dto.Amount.Value, ProductId = dto.ProductId.Value, RowDiscount = dto.Discount, ReceiptId = dto.ReceiptId.Value }); }