public bool Add(PurchaseBillViewModel entity) { var purchaseBill = entity.MapToPuchaseBill(); purchaseBill.PurchaseBillId = IdUtilities.GenerateByTimeSpan(); purchaseBill.CreatedDate = DateTime.Now; purchaseBill.StaffId = StaffGlobal.StaffId; _purchaseBillRepository.Add(purchaseBill); //purchaseBill.PurchaseBillDetails = new List<PurchaseBillDetail>(); //var purchaseBillDetails = new List<PurchaseBillDetail>(); foreach (var item in entity.PurchaseBillDetailViewModels) { var purchaseBillDetail = item.MapToPurchaseBillDetail(); purchaseBillDetail.PurchaseBillId = purchaseBill.PurchaseBillId; _purchaseBillDetailRepository.Add(purchaseBillDetail); } return(true); }
public bool Add(SaleBillViewModel entity) { if (entity == null) { return(false); } var saleBill = entity.MapToSaleBill(); saleBill.SaleBillId = IdUtilities.GenerateByTimeSpan(); saleBill.CreatedDate = DateTime.Now; saleBill.StaffId = StaffGlobal.CurrentStaff.StaffId; _saleBillRepository.Add(saleBill); foreach (var item in entity.SaleBillDetailViewModels) { var saleBillDetail = item.MapToSaleBillDetail(); saleBillDetail.SaleBillId = saleBill.SaleBillId; _saleBillDetailRepository.Add(saleBillDetail); } return(true); }