private CreditNote Map(tblDocument tblDoc) { var cn = new CreditNote(tblDoc.Id); _Map(tblDoc, cn); cn.InvoiceId = tblDoc.InvoiceOrderId == null ? Guid.Empty : tblDoc.InvoiceOrderId.Value; cn._SetLineItems(tblDoc.tblLineItems.Select(n => MapCreditLineItem(n)).ToList()); return cn; }
public void SaveCommandCN() { using (StructureMap.IContainer c = NestedContainer) { note = new CreditNote(Guid.NewGuid()); note.DocumentDateIssued = DateTime.Now; note.DocumentIssuerCostCentre = Using<ICostCentreRepository>(c).GetById(Using<IConfigService>(c).Load().CostCentreId); note.DocumentIssuerCostCentreApplicationId = Using<IConfigService>(c).Load().CostCentreApplicationId; note.DocumentIssuerUser = Using<IUserRepository>(c).GetById(Using<IConfigService>(c).ViewModelParameters.CurrentUserId); note.DocumentRecipientCostCentre = Using<ICostCentreRepository>(c).GetById( Using<IConfigService>(c).Load().CostCentreId); note.DocumentReference = ""; note.InvoiceId = InvoiceNo; note.DocumentType = DocumentType.InventoryTransferNote; List<CreditNoteLineItem> ListitnLineitem = new List<CreditNoteLineItem>(); //foreach (EditCNItemsViewModel item in LineItems) //{ CreditNoteLineItem itnLineitem = new CreditNoteLineItem(Guid.NewGuid()) { Description = Description, LineItemSequenceNo = 0, LineItemVatValue = LineItemVatValue, Product = Using<IProductRepository>(c).GetById(ProductId), Qty = Qty, IsNew = true, Value = Value }; ListitnLineitem.Add(itnLineitem); //} note._SetLineItems(ListitnLineitem); } }