public DiscountService(IServiceProvider serviceProvider, PosDbContext dbContext) { DbContext = dbContext; ServiceProvider = serviceProvider; DbSet = dbContext.Set <Discount>(); DbSetDiscountStore = dbContext.Set <DiscountStore>(); IdentityService = serviceProvider.GetService <IIdentityService>(); }
public SalesDocReturnService(IServiceProvider serviceProvider, PosDbContext dbContext, ISalesDocService salesDocService) { DbContext = dbContext; ServiceProvider = serviceProvider; DbSet = dbContext.Set <SalesDocReturn>(); DbSetSalesDoc = dbContext.Set <SalesDoc>(); DbSetSales = DbContext.Set <SalesDocDetailReturnItem>(); salesDocFacade = salesDocService; IdentityService = serviceProvider.GetService <IIdentityService>(); }
public SalesDocService(IServiceProvider serviceProvider, PosDbContext dbContext) { DbContext = dbContext; ServiceProvider = serviceProvider; DbSet = dbContext.Set <SalesDoc>(); IdentityService = serviceProvider.GetService <IIdentityService>(); }
public BaseRepository(PosDbContext dbContext) { if (dbContext == null) { throw new ArgumentNullException("dbContext"); } Db = dbContext; DbSet = dbContext.Set <T>(); }
public async Task CreateSale(SaleModelView model) { Sale create = new Sale { SaleId = Guid.NewGuid(), TotalAmount = model.TotalAmount, NoOfItem = model.NoOfProduct, Create = DateTime.Now, Modify = DateTime.Now, Note = "", CreateBy = Guid.NewGuid(), ModifyBy = Guid.NewGuid() }; await Create(create); if (create.SaleId != null) { foreach (SaleDetailsViewModel item in model.SaleDetails) { SaleDetails product = new SaleDetails(); product.SaleId = create.SaleId; product.Quantity = item.Quantity; product.ProductId = item.ProductId; product.Price = item.Price; product.MeasureType = item.Unit.ToString(); product.Create = DateTime.Now; product.CreateBy = Guid.NewGuid(); product.Modify = DateTime.Now; product.ModifyBy = Guid.NewGuid(); _context.Set <SaleDetails>().AddAsync(product); } } await _context.SaveChangesAsync(); }
public SalesDocViewModel MaptoViewModel(SalesDoc model) { SalesDocViewModel viewModel = new SalesDocViewModel(); PropertyCopier <SalesDoc, SalesDocViewModel> .Copy(model, viewModel); var salesdoc = DbContext.Set <SalesDoc>().Where(x => x.Id == model.Id).FirstOrDefault(); viewModel.Active = model.Active; viewModel.date = model.Date; viewModel.discount = model.Discount; viewModel.grandTotal = model.GrandTotal; viewModel.Id = model.Id; viewModel.reference = model.Reference; viewModel.remark = model.Remark; viewModel.code = model.Code; viewModel.isReturn = model.isReturn; viewModel.isVoid = model.isVoid; viewModel.salesDetail = new SalesDetail { bank = new Bank { code = model.BankCode, description = "", name = model.BankName, _id = model.BankId }, bankCard = new Bank { code = model.BankCardCode, description = "", name = model.BankCardName, _id = model.BankCardId }, cardAmount = model.CardAmount, cardName = model.CardName, cardNumber = model.CardNumber, cardType = new Card { code = model.CardTypeCode, description = "", name = model.CardTypeName, _id = model.CardTypeId }, cashAmount = model.CashAmount, paymentType = model.PaymentType, voucher = new Voucher { value = model.VoucherValue }, card = model.Card }; var Store = GetStore(salesdoc.StoreCode); viewModel.store = new Store { Code = model.StoreCode, Name = model.StoreName, Id = model.StoreId, Address = Store.address, Phone = Store.phone, StoreCategory = model.StoreCategory, Storage = new StorageViewModel { code = model.StoreStorageCode, name = model.StoreStorageName, _id = model.StoreStorageId, } }; viewModel.shift = model.Shift; viewModel.subTotal = model.SubTotal; viewModel.totalProduct = model.TotalProduct; viewModel.grandTotal = model.GrandTotal; viewModel.totalDiscount = model.Discount; viewModel.Id = model.Id; viewModel.items = new List <SalesDocDetailViewModel>(); foreach (SalesDocDetail i in model.Details) { SalesDocDetailViewModel salesDocDetailViewModel = new SalesDocDetailViewModel(); PropertyCopier <SalesDocDetail, SalesDocDetailViewModel> .Copy(i, salesDocDetailViewModel); salesDocDetailViewModel.Id = i.Id; salesDocDetailViewModel.item = new ViewModels.NewIntegrationViewModel.ItemViewModel { ArticleRealizationOrder = i.ItemArticleRealizationOrder, code = i.ItemCode, DomesticCOGS = i.ItemDomesticCOGS, DomesticRetail = i.ItemDomesticRetail, DomesticSale = i.ItemDomesticSale, DomesticWholeSale = i.ItemDomesticWholeSale, name = i.ItemName, Size = i.ItemSize, Uom = i.ItemUom, _id = i.ItemId }; salesDocDetailViewModel.discount1 = i.Discount1; salesDocDetailViewModel.discount2 = i.Discount2; salesDocDetailViewModel.discountNominal = i.DiscountNominal; salesDocDetailViewModel.itemCode = i.ItemCode; salesDocDetailViewModel.itemId = (int)i.ItemId; salesDocDetailViewModel.margin = i.Margin; salesDocDetailViewModel.price = i.Price; salesDocDetailViewModel.quantity = i.Quantity; salesDocDetailViewModel.specialDiscount = i.SpesialDiscount; salesDocDetailViewModel.total = i.Total; viewModel.items.Add(salesDocDetailViewModel); } return(viewModel); }
public SalesDocReturnViewModel MapToViewModel(SalesDocReturn model) { SalesDocReturnViewModel viewModel = new SalesDocReturnViewModel(); PropertyCopier <SalesDocReturn, SalesDocReturnViewModel> .Copy(model, viewModel); viewModel.code = model.Code; viewModel.date = model.Date; viewModel.Id = model.Id; viewModel.isVoid = model.IsVoid; var sales = DbContext.Set <SalesDoc>().Include(x => x.Details).Where(x => x.Id == model.SalesDocId).FirstOrDefault(); var salesitems = new List <SalesDocDetailViewModel>(); foreach (SalesDocDetail i in sales.Details) { SalesDocDetailViewModel salesDocDetailViewModel = new SalesDocDetailViewModel(); PropertyCopier <SalesDocDetail, SalesDocDetailViewModel> .Copy(i, salesDocDetailViewModel); salesDocDetailViewModel.Id = i.Id; salesDocDetailViewModel.item = new Bateeq.Service.Pos.Lib.ViewModels.NewIntegrationViewModel.ItemViewModel { ArticleRealizationOrder = i.ItemArticleRealizationOrder, code = i.ItemCode, DomesticCOGS = i.ItemDomesticCOGS, DomesticRetail = i.ItemDomesticRetail, DomesticSale = i.ItemDomesticSale, DomesticWholeSale = i.ItemDomesticWholeSale, name = i.ItemName, Size = i.ItemSize, Uom = i.ItemUom, _id = i.ItemId }; salesDocDetailViewModel.discount1 = i.Discount1; salesDocDetailViewModel.discount2 = i.Discount2; salesDocDetailViewModel.discountNominal = i.DiscountNominal; salesDocDetailViewModel.itemCode = i.ItemCode; salesDocDetailViewModel.itemId = (int)i.ItemId; salesDocDetailViewModel.margin = i.Margin; salesDocDetailViewModel.price = i.Price; salesDocDetailViewModel.quantity = i.Quantity; salesDocDetailViewModel.specialDiscount = i.SpesialDiscount; salesDocDetailViewModel.total = i.Total; salesitems.Add(salesDocDetailViewModel); } viewModel.sales = new Bateeq.Service.Pos.Lib.ViewModels.SalesDoc.SalesDocViewModel { Active = sales.Active, date = sales.Date, discount = sales.Discount, grandTotal = sales.GrandTotal, Id = sales.Id, reference = sales.Reference, remark = sales.Remark, code = sales.Code, isReturn = sales.isReturn, isVoid = sales.isVoid, salesDetail = new SalesDetail { bank = new Bank { code = sales.BankCode, description = "", name = sales.BankName, _id = sales.BankId }, bankCard = new Bank { code = sales.BankCardCode, description = "", name = sales.BankCardName, _id = sales.BankCardId }, cardAmount = sales.CardAmount, cardName = sales.CardName, cardNumber = sales.CardNumber, cardType = new Card { code = sales.CardTypeCode, description = "", name = sales.CardTypeName, _id = sales.CardTypeId }, cashAmount = sales.CashAmount, paymentType = sales.PaymentType, voucher = new Voucher { value = sales.VoucherValue }, card = sales.Card }, store = new Store { Code = sales.StoreCode, Name = sales.StoreName, Id = sales.StoreId, Storage = new StorageViewModel { code = sales.StoreStorageCode, name = model.StoreStorageName, _id = model.StoreStorageId, } }, shift = sales.Shift, subTotal = sales.SubTotal, totalProduct = sales.TotalProduct, items = salesitems }; var salesreturn = DbContext.Set <SalesDoc>().Include(x => x.Details).Where(x => x.Id == model.SalesDocReturnId).FirstOrDefault(); var salesreturnitems = new List <SalesDocDetailViewModel>(); foreach (SalesDocDetail i in salesreturn.Details) { SalesDocDetailViewModel salesDocDetailViewModel = new SalesDocDetailViewModel(); PropertyCopier <SalesDocDetail, SalesDocDetailViewModel> .Copy(i, salesDocDetailViewModel); salesDocDetailViewModel.Id = i.Id; salesDocDetailViewModel.item = new Bateeq.Service.Pos.Lib.ViewModels.NewIntegrationViewModel.ItemViewModel { ArticleRealizationOrder = i.ItemArticleRealizationOrder, code = i.ItemCode, DomesticCOGS = i.ItemDomesticCOGS, DomesticRetail = i.ItemDomesticRetail, DomesticSale = i.ItemDomesticSale, DomesticWholeSale = i.ItemDomesticWholeSale, name = i.ItemName, Size = i.ItemSize, Uom = i.ItemUom, _id = i.ItemId }; salesDocDetailViewModel.discount1 = i.Discount1; salesDocDetailViewModel.discount2 = i.Discount2; salesDocDetailViewModel.discountNominal = i.DiscountNominal; salesDocDetailViewModel.itemCode = i.ItemCode; salesDocDetailViewModel.itemId = (int)i.ItemId; salesDocDetailViewModel.margin = i.Margin; salesDocDetailViewModel.price = i.Price; salesDocDetailViewModel.quantity = i.Quantity; salesDocDetailViewModel.specialDiscount = i.SpesialDiscount; salesDocDetailViewModel.total = i.Total; salesDocDetailViewModel.isReturn = i.isReturn; salesDocDetailViewModel.returnItems = new List <SalesDocDetailViewModel>(); if (i.isReturn) { var a = DbContext.SalesDocDetailReturnItems.Where(x => x.SalesDocDetailId == i.Id).ToList(); foreach (var retur in a) { SalesDocDetailViewModel salesDocDetailreturnitemViewModel = new SalesDocDetailViewModel(); PropertyCopier <SalesDocDetail, SalesDocDetailViewModel> .Copy(i, salesDocDetailreturnitemViewModel); salesDocDetailreturnitemViewModel.Id = retur.Id; salesDocDetailreturnitemViewModel.item = new Bateeq.Service.Pos.Lib.ViewModels.NewIntegrationViewModel.ItemViewModel { ArticleRealizationOrder = retur.ItemArticleRealizationOrder, code = retur.ItemCode, DomesticCOGS = retur.ItemDomesticCOGS, DomesticRetail = retur.ItemDomesticRetail, DomesticSale = retur.ItemDomesticSale, DomesticWholeSale = retur.ItemDomesticWholeSale, name = retur.ItemName, Size = retur.ItemSize, Uom = retur.ItemUom, _id = retur.ItemId }; salesDocDetailreturnitemViewModel.discount1 = retur.Discount1; salesDocDetailreturnitemViewModel.discount2 = retur.Discount2; salesDocDetailreturnitemViewModel.discountNominal = retur.DiscountNominal; salesDocDetailreturnitemViewModel.itemCode = retur.ItemCode; salesDocDetailreturnitemViewModel.itemId = (int)retur.ItemId; salesDocDetailreturnitemViewModel.margin = retur.Margin; salesDocDetailreturnitemViewModel.price = retur.Price; salesDocDetailreturnitemViewModel.quantity = retur.Quantity; salesDocDetailreturnitemViewModel.specialDiscount = retur.SpesialDiscount; salesDocDetailreturnitemViewModel.total = retur.Total; salesDocDetailViewModel.returnItems.Add(salesDocDetailreturnitemViewModel); } } salesreturnitems.Add(salesDocDetailViewModel); } viewModel.salesDocReturn = new SalesDocViewModel { Active = salesreturn.Active, date = salesreturn.Date, discount = salesreturn.Discount, grandTotal = salesreturn.GrandTotal, Id = salesreturn.Id, reference = salesreturn.Reference, remark = salesreturn.Remark, code = salesreturn.Code, isReturn = salesreturn.isReturn, isVoid = salesreturn.isVoid, salesDetail = new SalesDetail { bank = new Bank { code = salesreturn.BankCode, description = "", name = salesreturn.BankName, _id = salesreturn.BankId }, bankCard = new Bank { code = salesreturn.BankCardCode, description = "", name = salesreturn.BankCardName, _id = salesreturn.BankCardId }, cardAmount = salesreturn.CardAmount, cardName = salesreturn.CardName, cardNumber = salesreturn.CardNumber, cardType = new Card { code = salesreturn.CardTypeCode, description = "", name = salesreturn.CardTypeName, _id = salesreturn.CardTypeId }, cashAmount = salesreturn.CashAmount, paymentType = salesreturn.PaymentType, voucher = new Voucher { value = salesreturn.VoucherValue }, card = salesreturn.Card }, store = new Store { Code = salesreturn.StoreCode, Name = salesreturn.StoreName, Id = salesreturn.StoreId, Storage = new StorageViewModel { code = salesreturn.StoreStorageCode, name = salesreturn.StoreStorageName, _id = salesreturn.StoreStorageId, } }, shift = salesreturn.Shift, subTotal = salesreturn.SubTotal, totalProduct = salesreturn.TotalProduct, totalBayar = salesreturn.GrandTotal, totalDiscount = salesreturn.Discount, total = salesreturn.GrandTotal, items = salesreturnitems }; viewModel._CreatedAgent = model._CreatedAgent; viewModel._CreatedBy = model._CreatedBy; viewModel._CreatedUtc = model._CreatedUtc; viewModel._IsDeleted = model._IsDeleted; viewModel._LastModifiedAgent = model._LastModifiedAgent; viewModel._LastModifiedUtc = model._LastModifiedUtc; viewModel._LastModifiedBy = model._LastModifiedBy; var store = GetStore(salesreturn.StoreCode); viewModel.store = new Store { Id = salesreturn.StoreId, Code = salesreturn.StoreCode, Name = salesreturn.StoreName, Address = store.address, Phone = store.phone }; viewModel.items = new List <SalesDocReturnDetailViewModel>(); foreach (var i in model.Details) { SalesDocReturnDetailViewModel salesDocDetailViewModel = new SalesDocReturnDetailViewModel(); PropertyCopier <SalesDocReturnDetail, SalesDocReturnDetailViewModel> .Copy(i, salesDocDetailViewModel); salesDocDetailViewModel.Id = i.Id; salesDocDetailViewModel.Active = i.Active; salesDocDetailViewModel.discount1 = i.Discount1; salesDocDetailViewModel.discount2 = i.Discount2; salesDocDetailViewModel.discountNominal = i.DiscountNominal; salesDocDetailViewModel.isReturn = i.isReturn; salesDocDetailViewModel.itemCode = i.ItemCode; salesDocDetailViewModel.itemId = (int)i.ItemId; salesDocDetailViewModel.item = new SalesDocDetailViewModel { discount1 = i.Discount1, discount2 = i.Discount2, discountNominal = i.DiscountNominal, itemCode = i.ItemCode, itemId = (int)i.ItemId, margin = i.Margin, price = i.Price, quantity = i.Quantity, specialDiscount = i.SpesialDiscount, total = i.Total, item = new Bateeq.Service.Pos.Lib.ViewModels.NewIntegrationViewModel.ItemViewModel { ArticleRealizationOrder = i.ItemArticleRealizationOrder, code = i.ItemCode, DomesticCOGS = i.ItemDomesticCOGS, DomesticRetail = i.ItemDomesticRetail, DomesticSale = i.ItemDomesticSale, DomesticWholeSale = i.ItemDomesticWholeSale, name = i.ItemName, Size = i.ItemSize, Uom = i.ItemUom, _id = i.ItemId } }; salesDocDetailViewModel.margin = i.Margin; salesDocDetailViewModel.price = i.Price; salesDocDetailViewModel.quantity = i.Quantity; salesDocDetailViewModel.specialDiscount = i.SpesialDiscount; salesDocDetailViewModel.total = i.Total; salesDocDetailViewModel.returnItems = new List <SalesDocDetailViewModel>(); foreach (var d in salesreturn.Details) { SalesDocDetailViewModel salesDocDetailreturnViewModel = new SalesDocDetailViewModel(); PropertyCopier <SalesDocDetail, SalesDocDetailViewModel> .Copy(d, salesDocDetailreturnViewModel); salesDocDetailreturnViewModel.Id = d.Id; salesDocDetailreturnViewModel.item = new Bateeq.Service.Pos.Lib.ViewModels.NewIntegrationViewModel.ItemViewModel { ArticleRealizationOrder = d.ItemArticleRealizationOrder, code = d.ItemCode, DomesticCOGS = d.ItemDomesticCOGS, DomesticRetail = d.ItemDomesticRetail, DomesticSale = d.ItemDomesticSale, DomesticWholeSale = d.ItemDomesticWholeSale, name = d.ItemName, Size = d.ItemSize, Uom = d.ItemUom, _id = d.ItemId }; salesDocDetailreturnViewModel.discount1 = d.Discount1; salesDocDetailreturnViewModel.discount2 = d.Discount2; salesDocDetailreturnViewModel.discountNominal = d.DiscountNominal; salesDocDetailreturnViewModel.itemCode = d.ItemCode; salesDocDetailreturnViewModel.itemId = (int)d.ItemId; salesDocDetailreturnViewModel.margin = d.Margin; salesDocDetailreturnViewModel.price = d.Price; salesDocDetailreturnViewModel.quantity = d.Quantity; salesDocDetailreturnViewModel.specialDiscount = d.SpesialDiscount; salesDocDetailreturnViewModel.total = d.Total; salesDocDetailViewModel.returnItems.Add(salesDocDetailreturnViewModel); } viewModel.items.Add(salesDocDetailViewModel); } return(viewModel); }
public IQueryable <TEntity> GetAll() { return(_posDbContext.Set <TEntity>().AsQueryable()); }