public async Task <WrapperPaymentStatusListVM> GetListPaged(GetDataListVM dataListVM) { System.Linq.Expressions.Expression <Func <PaymentStatus, bool> > globalFilterExpression = (x) => true; if (string.IsNullOrEmpty(dataListVM.GlobalFilter) || string.IsNullOrWhiteSpace(dataListVM.GlobalFilter)) { globalFilterExpression = (x) => true; } else { globalFilterExpression = (x) => x.Status.Contains(dataListVM.GlobalFilter); } var paymentStatusList = await _repositoryWrapper.PaymentStatus .FindAll() .Where(x => x.FactoryId == dataListVM.FactoryId) .Where(globalFilterExpression) .OrderByDescending(x => x.UpdatedDateTime) .Skip((dataListVM.PageNumber - 1) * (dataListVM.PageSize)) .Take(dataListVM.PageSize) .ToListAsync(); var dataRowCount = await _repositoryWrapper.PaymentStatus.NumOfRecord(); List <PaymentStatusVM> PaymentStatusVMLists = new List <PaymentStatusVM>(); PaymentStatusVMLists = _utilService.GetMapper().Map <List <PaymentStatus>, List <PaymentStatusVM> >(paymentStatusList); var wrapper = new WrapperPaymentStatusListVM() { ListOfData = PaymentStatusVMLists, TotalRecords = dataRowCount }; return(wrapper); }
public async Task <WrapperProductionListVM> GetListPaged(GetDataListVM dataListVM) { var dataList = await _repositoryWrapper.Production .FindAll() .Include(x => x.Item) .Include(x => x.ItemCategory) .Include(x => x.Equipment) .Include(x => x.Staff) .Include(x => x.ItemStatus) .Where(x => x.FactoryId == dataListVM.FactoryId) .ToListAsync(); var dataRowCount = await _repositoryWrapper.Production.NumOfRecord(); List <AddProductionVM> ProductionVMLists = new List <AddProductionVM>(); ProductionVMLists = _utilService.GetMapper().Map <List <Production>, List <AddProductionVM> >(dataList); if (string.IsNullOrEmpty(dataListVM.GlobalFilter) || string.IsNullOrWhiteSpace(dataListVM.GlobalFilter)) { ProductionVMLists = ProductionVMLists .OrderByDescending(x => x.EntryDate) .Skip((dataListVM.PageNumber - 1) * (dataListVM.PageSize)) .Take(dataListVM.PageSize) .ToList(); } else { ProductionVMLists = ProductionVMLists .Where((x) => //!string.IsNullOrEmpty(x.EquipmentName) && !string.IsNullOrWhiteSpace(x.EquipmentName) && x.EquipmentName.Contains(dataListVM.GlobalFilter) !string.IsNullOrEmpty(x.ItemCategoryName) && !string.IsNullOrWhiteSpace(x.ItemCategoryName) && x.ItemCategoryName.Contains(dataListVM.GlobalFilter) || !string.IsNullOrEmpty(x.ItemName) && !string.IsNullOrWhiteSpace(x.ItemName) && x.ItemName.Contains(dataListVM.GlobalFilter) || !string.IsNullOrEmpty(x.StaffName) && !string.IsNullOrWhiteSpace(x.StaffName) && x.StaffName.Contains(dataListVM.GlobalFilter)) .OrderByDescending(x => x.EntryDate) .Skip((dataListVM.PageNumber - 1) * (dataListVM.PageSize)) .Take(dataListVM.PageSize) .ToList(); } var wrapper = new WrapperProductionListVM() { ListOfData = ProductionVMLists, TotalRecords = dataRowCount }; this._utilService.LogInfo("Successful In Getting Item Category"); return(wrapper); }
public async Task <WrapperStaffListVM> Add(StaffVM ViewModel) { var itemToAdd = _utilService.GetMapper().Map <StaffVM, Staff>(ViewModel); itemToAdd = _repositoryWrapper.Staff.Create(itemToAdd); Task <int> t1 = _repositoryWrapper.Staff.SaveChangesAsync(); if (ViewModel.IsManager) { UserAuthInfo infoToAdd = new UserAuthInfo() { FactoryId = ViewModel.FactoryId, Password = ViewModel.Password, UserId = itemToAdd.Id, UserName = ViewModel.UserName, }; infoToAdd = _repositoryWrapper.UserAuthInfo.Create(infoToAdd); UserRole userRoleToAdd = new UserRole() { FactoryId = ViewModel.FactoryId, RoleId = ViewModel.RoleId, UserId = infoToAdd.Id }; userRoleToAdd = _repositoryWrapper.UserRole.Create(userRoleToAdd); Task <int> t2 = _repositoryWrapper.UserAuthInfo.SaveChangesAsync(); Task <int> t3 = _repositoryWrapper.UserRole.SaveChangesAsync(); await Task.WhenAll(t2, t3); } await Task.WhenAll(t1); this._utilService.Log("Successful In Adding Data"); var dataParam = new GetDataListVM() { FactoryId = itemToAdd.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperStaffListVM data = await GetListPaged(dataParam, true); return(data); }
public async Task <WrapperListCustomerVM> Add(CustomerVM addCustomerViewModel) { var CustomerDT = _utilService.GetMapper().Map <CustomerVM, Customer>(addCustomerViewModel); // var AddressDT = _mapper.Map<AddCustomerViewModel, Address>(addCustomerViewModel); // var PhoneDT = _mapper.Map<AddCustomerViewModel, Phone>(addCustomerViewModel); //Task<string> cusUnique = _repositoryWrapper.Customer.GetUniqueId(); //Task<string> addressUnique = _repositoryWrapper.Address.GetUniqueId(); //Task<string> phoneUnique = _repositoryWrapper.Phone.GetUniqueId(); //await Task.WhenAll(cusUnique, addressUnique, phoneUnique); //CustomerDT.UniqueId = cusUnique.Result; //AddressDT.UniqueId = addressUnique.Result; //PhoneDT.UniqueId = phoneUnique.Result; CustomerDT = _repositoryWrapper.Customer.Create(CustomerDT); //AddressDT.RelatedId = CustomerDT.Id; //AddressDT = _repositoryWrapper.Address.Create(AddressDT); //PhoneDT.RelatedId = CustomerDT.Id; //PhoneDT = _repositoryWrapper.Phone.Create(PhoneDT); Task <int> t1 = _repositoryWrapper.Customer.SaveChangesAsync(); //Task<int> t2 = _repositoryWrapper.Address.SaveChangesAsync(); //Task<int> t3 = _repositoryWrapper.Phone.SaveChangesAsync(); //// await _repositoryWrapper.SaveAsync(); await Task.WhenAll(t1); this._utilService.Log("Successful In saving"); var dataParam = new GetDataListVM() { FactoryId = addCustomerViewModel.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperListCustomerVM data = await GetListPaged(dataParam, true); return(data); }
public async Task <WrapperStockListVM> Add(StockVM ViewModel) { var itemToAdd = _utilService.GetMapper().Map <StockVM, Stock>(ViewModel); itemToAdd = _repositoryWrapper.Stock.Create(itemToAdd); Task <int> t1 = _repositoryWrapper.Stock.SaveChangesAsync(); await Task.WhenAll(t1); this._utilService.Log("Successful In Adding Data"); var dataParam = new GetDataListVM() { FactoryId = itemToAdd.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperStockListVM data = await GetListPaged(dataParam); return(data); }
public async Task <WrapperEquipmentListVM> GetListPaged(GetDataListVM dataListVM) { System.Linq.Expressions.Expression <Func <Equipment, bool> > globalFilterExpression = (x) => true; if (string.IsNullOrEmpty(dataListVM.GlobalFilter) || string.IsNullOrWhiteSpace(dataListVM.GlobalFilter)) { globalFilterExpression = (x) => true; } else { globalFilterExpression = (x) => x.Name.Contains(dataListVM.GlobalFilter) || x.EquipmentCategory.Name.Contains(dataListVM.GlobalFilter) || x.Price.ToString().Contains(dataListVM.GlobalFilter) || x.Description.Contains(dataListVM.GlobalFilter); } var EquipmentList = await _repositoryWrapper.Equipment .FindAll() .Where(x => x.FactoryId == dataListVM.FactoryId) .Include(x => x.EquipmentCategory) .Where(globalFilterExpression) .OrderByDescending(x => x.UpdatedDateTime) .Skip((dataListVM.PageNumber - 1) * dataListVM.PageSize) .Take(dataListVM.PageSize) .ToListAsync(); var dataRowCount = await _repositoryWrapper.Equipment.NumOfRecord(); List <EquipmentVM> EquipmentVMList = new List <EquipmentVM>(); EquipmentVMList = _utilService.GetMapper().Map <List <Equipment>, List <EquipmentVM> >(EquipmentList); var wrapper = new WrapperEquipmentListVM() { ListOfData = EquipmentVMList, TotalRecords = dataRowCount }; return(wrapper); }
// ALTER TABLE Role ADD column_name bit; public async Task <WrapperRoleListVM> GetListPaged(GetDataListVM dataListVM) { //System.Linq.Expressions.Expression<Func<Role, bool>> globalFilterExpression = (x) => true; //if (string.IsNullOrEmpty(dataListVM.GlobalFilter) || string.IsNullOrWhiteSpace(dataListVM.GlobalFilter)) //{ // globalFilterExpression = (x) => true; //} //else //{ // globalFilterExpression = (x) => // x.Name.Contains(dataListVM.GlobalFilter); //} var itemCatagoryList = await _repositoryWrapper .Role .FindAll() // .Where(x => x.FactoryId == dataListVM.FactoryId) // .Where(globalFilterExpression) //.OrderByDescending(x => x.UpdatedDateTime) //.Skip((dataListVM.PageNumber - 1) * (dataListVM.PageSize)) //.Take(dataListVM.PageSize) .ToListAsync(); var dataRowCount = await _repositoryWrapper.Role.NumOfRecord(); List <RoleVM> RoleVMLists = new List <RoleVM>(); RoleVMLists = _utilService.GetMapper().Map <List <Role>, List <RoleVM> >(itemCatagoryList); var wrapper = new WrapperRoleListVM() { ListOfData = RoleVMLists, TotalRecords = dataRowCount }; this._utilService.LogInfo("Successful In Getting Item Category"); return(wrapper); }
public async Task <WrapperUserAuthInfoListVM> GetListPaged(GetDataListVM dataListVM) { System.Linq.Expressions.Expression <Func <UserAuthInfo, bool> > globalFilterExpression = (x) => true; if (string.IsNullOrEmpty(dataListVM.GlobalFilter) || string.IsNullOrWhiteSpace(dataListVM.GlobalFilter)) { globalFilterExpression = (x) => true; } else { globalFilterExpression = (x) => x.UserName.Contains(dataListVM.GlobalFilter); } var itemCatagoryList = await _repositoryWrapper.UserAuthInfo .FindAll() .Where(x => x.FactoryId == dataListVM.FactoryId) .Where(globalFilterExpression) .OrderByDescending(x => x.UpdatedDateTime) .Skip((dataListVM.PageNumber - 1) * (dataListVM.PageSize)) .Take(dataListVM.PageSize) .ToListAsync(); var dataRowCount = await _repositoryWrapper.UserAuthInfo.NumOfRecord(); List <UserAuthInfoVM> UserAuthInfoVMLists = new List <UserAuthInfoVM>(); UserAuthInfoVMLists = _utilService.GetMapper().Map <List <UserAuthInfo>, List <UserAuthInfoVM> >(itemCatagoryList); var wrapper = new WrapperUserAuthInfoListVM() { ListOfData = UserAuthInfoVMLists, TotalRecords = dataRowCount }; this._utilService.LogInfo("Successful In Getting Item Category"); return(wrapper); }
public async Task <WrapperItemStatusListVM> Add(ItemStatusVM vm) { var entityToAdd = _utilService.GetMapper().Map <ItemStatusVM, ItemStatus>(vm); //string uniqueIdTask =await _repositoryWrapper.ItemStatus.GetUniqueId(); //// Todo need to aandle unique id from db //entityToAdd.UniqueId = uniqueIdTask; entityToAdd = _repositoryWrapper.ItemStatus.Create(entityToAdd); await _repositoryWrapper.ItemStatus.SaveChangesAsync(); this._utilService.LogInfo("Successful In saving Item Category"); var dataParam = new GetDataListVM() { FactoryId = vm.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperItemStatusListVM data = await GetListPaged(dataParam); return(data); }
public async Task <WrapperFactoryListVM> Add(FactoryVM vm) { var entityToAdd = _utilService.GetMapper().Map <FactoryVM, Factory>(vm); entityToAdd = this._repositoryWrapper.Factory.Create(entityToAdd); #region Invoice Type this._repositoryWrapper.InvoiceType.Create(new InvoiceType() { FactoryId = entityToAdd.Id, Name = "Expense", }); this._repositoryWrapper.InvoiceType.Create(new InvoiceType() { FactoryId = entityToAdd.Id, Name = "Income", }); this._repositoryWrapper.InvoiceType.Create(new InvoiceType() { FactoryId = entityToAdd.Id, Name = "SalesReturn", }); this._repositoryWrapper.InvoiceType.Create(new InvoiceType() { FactoryId = entityToAdd.Id, Name = "PurchaseReturn", }); this._repositoryWrapper.InvoiceType.Create(new InvoiceType() { FactoryId = entityToAdd.Id, Name = "StaffProduction", }); this._repositoryWrapper.InvoiceType.Create(new InvoiceType() { FactoryId = entityToAdd.Id, Name = "StaffPayment", }); this._repositoryWrapper.InvoiceType.Create(new InvoiceType() { FactoryId = entityToAdd.Id, Name = "SupplierPayment", }); this._repositoryWrapper.InvoiceType.Create(new InvoiceType() { FactoryId = entityToAdd.Id, Name = "ClientPayment", }); this._repositoryWrapper.InvoiceType.Create(new InvoiceType() { FactoryId = entityToAdd.Id, Name = "Purchase", }); this._repositoryWrapper.InvoiceType.Create(new InvoiceType() { FactoryId = entityToAdd.Id, Name = "Sales", }); #endregion #region Income Type this._repositoryWrapper.IncomeType.Create(new IncomeType() { FactoryId = entityToAdd.Id, Name = "PurchaseReturn" }); this._repositoryWrapper.IncomeType.Create(new IncomeType() { FactoryId = entityToAdd.Id, Name = "ClientPaymentRecieved" }); this._repositoryWrapper.IncomeType.Create(new IncomeType() { FactoryId = entityToAdd.Id, Name = "Sales" }); #endregion #region Expense Type this._repositoryWrapper.ExpenseType.Create(new ExpenseType() { FactoryId = entityToAdd.Id, Name = "SalesReturn" }); this._repositoryWrapper.ExpenseType.Create(new ExpenseType() { FactoryId = entityToAdd.Id, Name = "StaffPayment" }); this._repositoryWrapper.ExpenseType.Create(new ExpenseType() { FactoryId = entityToAdd.Id, Name = "SupplierPayment" }); this._repositoryWrapper.ExpenseType.Create(new ExpenseType() { FactoryId = entityToAdd.Id, Name = "Purchase" }); #endregion #region Payment Status this._repositoryWrapper.PaymentStatus.Create(new PaymentStatus() { FactoryId = entityToAdd.Id, Status = "CASH_PAID" }); this._repositoryWrapper.PaymentStatus.Create(new PaymentStatus() { FactoryId = entityToAdd.Id, Status = "CASH_RECIEVABLE" }); this._repositoryWrapper.PaymentStatus.Create(new PaymentStatus() { FactoryId = entityToAdd.Id, Status = "CASH_PAYABLE" }); this._repositoryWrapper.PaymentStatus.Create(new PaymentStatus() { FactoryId = entityToAdd.Id, Status = "CASH_RECIEVED" }); #endregion #region Item Status this._repositoryWrapper.ItemStatus.Create(new ItemStatus() { FactoryId = entityToAdd.Id, Name = "BAD" }); this._repositoryWrapper.ItemStatus.Create(new ItemStatus() { FactoryId = entityToAdd.Id, Name = "GOOD" }); #endregion Task <int> t1 = _repositoryWrapper.Factory.SaveChangesAsync(); Task <int> t2 = _repositoryWrapper.InvoiceType.SaveChangesAsync(); Task <int> t3 = _repositoryWrapper.ExpenseType.SaveChangesAsync(); Task <int> t4 = _repositoryWrapper.PaymentStatus.SaveChangesAsync(); Task <int> t5 = _repositoryWrapper.ItemStatus.SaveChangesAsync(); Task <int> t6 = _repositoryWrapper.IncomeType.SaveChangesAsync(); await Task.WhenAll(t1, t2, t3, t4, t5, t6); var dataParam = new GetDataListVM() { FactoryId = vm.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperFactoryListVM data = await GetListPaged(dataParam); return(data); }
public async Task <WrapperIncomeListVM> GetListPaged(GetDataListVM dataListVM) { //System.Linq.Expressions.Expression<Func<Income, bool>> globalFilterExpression = (x) => true; //if (string.IsNullOrEmpty(dataListVM.GlobalFilter) || string.IsNullOrWhiteSpace(dataListVM.GlobalFilter)) //{ // globalFilterExpression = (x) => true; //} //else //{ // globalFilterExpression = (x) => // x.Customer.Name.Contains(dataListVM.GlobalFilter); //} var incomeList = await _repositoryWrapper .Income .FindAll() .Where(x => x.FactoryId == dataListVM.FactoryId) .Include(x => x.Supplier) .Include(x => x.Customer) .Include(x => x.Staff) .Include(x => x.IncomeType) //.Where(globalFilterExpression) .OrderByDescending(x => x.UpdatedDateTime) .Skip((dataListVM.PageNumber - 1) * (dataListVM.PageSize)) .Take(dataListVM.PageSize) .ToListAsync(); //var incomeList_1 = await _repositoryWrapper // .Income // .FindAll() // .Where(x => x.FactoryId == dataListVM.FactoryId) // .Include(x => x.Staff) // .Include(x => x.IncomeType) // //.Where(globalFilterExpression) // .OrderByDescending(x => x.UpdatedDateTime) // .Skip((dataListVM.PageNumber - 1) * (dataListVM.PageSize)) // .Take(dataListVM.PageSize) // .ToListAsync(); //var incomeList_2 = await _repositoryWrapper // .Income // .FindAll() // .Where(x => x.FactoryId == dataListVM.FactoryId) // .Include(x => x.Supplier) // .Include(x => x.IncomeType) // //.Where(globalFilterExpression) // .OrderByDescending(x => x.UpdatedDateTime) // .Skip((dataListVM.PageNumber - 1) * (dataListVM.PageSize)) // .Take(dataListVM.PageSize) // .ToListAsync(); //incomeList = _utilService.ConcatList<Income>(incomeList.ToList(), _utilService.ConcatList<Income>(incomeList_1, incomeList_2)); var dataRowCount = await _repositoryWrapper.Income.NumOfRecord(); List <IncomeVM> IncomeVMLists = new List <IncomeVM>(); IncomeVMLists = _utilService.GetMapper().Map <List <Income>, List <IncomeVM> >(incomeList); var wrapper = new WrapperIncomeListVM() { ListOfData = IncomeVMLists, TotalRecords = dataRowCount }; return(wrapper); }