public async Task <WrapperStockListVM> GetListPaged(GetDataListVM dataListVM) { IEnumerable <Stock> ListTask = await _repositoryWrapper.Stock .FindByCondition(x => x.FactoryId == dataListVM.FactoryId) .Include(x => x.Item) .Include(x => x.ItemStatus) .ToListAsync(); long noOfRecordTask = await _repositoryWrapper.Stock.NumOfRecord(); List <Stock> List = ListTask.ToList().OrderByDescending(x => x.UpdatedDateTime).ToList();//.Skip((dataListVM.PageNumber - 1) * dataListVM.PageSize).Take(dataListVM.PageSize).OrderByDescending(x => x.CreatedDateTime).ToList(); List <StockVM> outputList = new List <StockVM>(); outputList = _utilService.GetMapper().Map <List <Stock>, List <StockVM> >(List); if (!string.IsNullOrEmpty(dataListVM.GlobalFilter) && !string.IsNullOrWhiteSpace(dataListVM.GlobalFilter)) { outputList = outputList.Where(output => output.ItemName != null ? output.ItemName.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false || output.ItemStatus != null ? output.ItemStatus.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false || output.Quantity.ToString() != null ? output.Quantity.ToString().Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false) .ToList(); } outputList = outputList.Skip((dataListVM.PageNumber - 1) * dataListVM.PageSize).Take(dataListVM.PageSize).ToList(); var data = new WrapperStockListVM(); data.ListOfData = outputList; data.TotalRecords = noOfRecordTask; this._utilService.Log("Successful In Getting Data"); return(data); }
public async Task <WrapperStaffListVM> Update(string id, StaffVM ViewModel) { if (id != ViewModel.Id) { new WrapperStaffListVM(); } Task <IEnumerable <Staff> > itemsDB = _repositoryWrapper.Staff.FindByConditionAsync(x => x.Id == id && x.FactoryId == ViewModel.FactoryId); await Task.WhenAll(itemsDB); var itemUpdated = _utilService.GetMapper().Map <StaffVM, Staff>(ViewModel, itemsDB.Result.ToList().FirstOrDefault()); _repositoryWrapper.Staff.Update(itemUpdated); Task <int> t1 = _repositoryWrapper.Staff.SaveChangesAsync(); await Task.WhenAll(t1); this._utilService.Log("Successful In Updating Data"); var dataParam = new GetDataListVM() { FactoryId = ViewModel.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperStaffListVM data = await GetListPaged(dataParam, true); return(data); }
public async Task <ActionResult <WrapperSupplierListVM> > GetAllSupplier(GetDataListVM temp) { var data = await _serviceWrapper.SupplierService.GetListPaged(temp, true); _utilService.Log("Supplier Successfully Getted"); return(Ok(data)); }
public async Task <WrapperStaffListVM> Delete(StaffVM Temp) { var Task = await _repositoryWrapper.Staff.FindByConditionAsync(x => x.Id == Temp.Id && x.FactoryId == Temp.FactoryId); var datarow = Task.ToList().FirstOrDefault(); if (datarow == null) { return(new WrapperStaffListVM()); } _repositoryWrapper.Staff.Delete(datarow); await _repositoryWrapper.Staff.SaveChangesAsync(); this._utilService.Log("Successful In Deleting Data"); var dataParam = new GetDataListVM() { FactoryId = Temp.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperStaffListVM data = await GetListPaged(dataParam, true); return(data); }
public async Task <InitialLoadDataVM> GetPaymentInitialData(GetDataListVM getDataListVM) { InitialLoadDataVM vm = new InitialLoadDataVM(); Task <WrapperListCustomerVM> customerListTask = _serviceWrapper.CustomerService.GetListPaged(getDataListVM, false); Task <WrapperIncomeTypeListVM> incomeTypeListTask = _serviceWrapper.IncomeTypeService.GetListPaged(getDataListVM); Task <WrapperInvoiceTypeListVM> invoiceTypeListTask = _serviceWrapper.InvoiceTypeService.GetListPaged(getDataListVM); Task <WrapperExpenseTypeListVM> expenseTypeTask = _serviceWrapper.ExpenseTypeService.GetListPaged(getDataListVM); Task <WrapperSupplierListVM> supplierListTask = _serviceWrapper.SupplierService.GetListPaged(getDataListVM, false); Task <WrapperStaffListVM> staffListTask = _serviceWrapper.StaffService.GetListPaged(getDataListVM, false); Task <WrapperItemListVM> itemTask = _serviceWrapper.ItemService.GetListPaged(getDataListVM); Task <WrapperItemCategoryListVM> itemCategoryTask = _serviceWrapper.ItemCategoryService.GetListPaged(getDataListVM); Task <WrapperItemStatusListVM> itemStatusTask = _serviceWrapper.ItemStatusService.GetListPaged(getDataListVM); await Task.WhenAll(customerListTask, incomeTypeListTask, invoiceTypeListTask, expenseTypeTask, supplierListTask, staffListTask , itemTask, itemCategoryTask, itemStatusTask); vm.CustomerVMs = customerListTask.Result.ListOfData; vm.IncomeTypeVMs = incomeTypeListTask.Result.ListOfData; vm.InvoiceTypeVMs = invoiceTypeListTask.Result.ListOfData; vm.ExpenseTypeVMs = expenseTypeTask.Result.ListOfData; vm.SupplierVMs = supplierListTask.Result.ListOfData; vm.StaffVMs = staffListTask.Result.ListOfData; vm.ItemCategoryVMs = itemCategoryTask.Result.ListOfData; vm.ItemVMs = itemTask.Result.ListOfData; vm.ItemStatusVMs = itemStatusTask.Result.ListOfData; return(vm); }
// Income // Transaction // Invoice public async Task <WrapperIncomeListVM> Add(IncomeVM vm) { var invoiceToAdd = _utilService.GetMapper().Map <IncomeVM, Invoice>(vm); var incomeToAdd = _utilService.GetMapper().Map <IncomeVM, Income>(vm); var transactionToAdd = _utilService.GetMapper().Map <IncomeVM, TblTransaction>(vm); //string uniqueIdTask =await _repositoryWrapper.Income.GetUniqueId(); //// Todo need to aandle unique id from db //entityToAdd.UniqueId = uniqueIdTask; _repositoryWrapper.Invoice.Create(invoiceToAdd); incomeToAdd.InvoiceId = invoiceToAdd.Id; _repositoryWrapper.Income.Create(incomeToAdd); transactionToAdd.InvoiceId = invoiceToAdd.Id; _repositoryWrapper.Transaction.Create(transactionToAdd); Task <int> t1 = _repositoryWrapper.Income.SaveChangesAsync(); Task <int> t2 = _repositoryWrapper.Invoice.SaveChangesAsync(); Task <int> t3 = _repositoryWrapper.Transaction.SaveChangesAsync(); await Task.WhenAll(t1, t2, t3); var dataParam = new GetDataListVM() { FactoryId = vm.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperIncomeListVM data = await GetListPaged(dataParam); return(data); }
public async Task <ActionResult <WrapperListCustomerVM> > GetAllCustomer(GetDataListVM customer) { var data = await _serviceWrapper.CustomerService.GetListPaged(customer, true); _utilService.Log("Customer Successfully Getted"); return(Ok(data)); }
public async Task <ActionResult <WrapperStockListVM> > GetAllStock(GetDataListVM temp) { var data = await _serviceWrapper.StockService.GetListPaged(temp); _utilService.Log("Stock Successfully Getted"); return(Ok(data)); }
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 <WrapperInvoiceTypeListVM> Delete(InvoiceTypeVM itemTemp) { IEnumerable <InvoiceType> itemTask = await _repositoryWrapper.InvoiceType.FindByConditionAsync(x => x.Id == itemTemp.Id && x.FactoryId == itemTemp.FactoryId); var item = itemTask.ToList().FirstOrDefault(); if (item == null) { return(new WrapperInvoiceTypeListVM()); } _repositoryWrapper.InvoiceType.Delete(item); await _repositoryWrapper.InvoiceType.SaveChangesAsync(); this._utilService.LogInfo("Successful In Deleting Item Cateory"); var dataParam = new GetDataListVM() { FactoryId = itemTemp.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperInvoiceTypeListVM data = await GetListPaged(dataParam); return(data); }
public async Task <WrapperStaffListVM> GetListPaged(GetDataListVM dataListVM, bool withHistory) { IEnumerable <Staff> ListTask = await _repositoryWrapper.Staff.FindByConditionAsync(x => x.FactoryId == dataListVM.FactoryId); long noOfRecordTask = await _repositoryWrapper.Staff.NumOfRecord(); List <Staff> List = ListTask.ToList().OrderByDescending(x => x.UpdatedDateTime).ToList();//.Skip((dataListVM.PageNumber - 1) * dataListVM.PageSize).Take(dataListVM.PageSize).OrderByDescending(x => x.CreatedDateTime).ToList(); List <StaffVM> outputList = new List <StaffVM>(); outputList = _utilService.GetMapper().Map <List <Staff>, List <StaffVM> >(List); List <UserRole> userRoleListT = await _repositoryWrapper .UserRole .FindAll() .Where(x => x.FactoryId == dataListVM.FactoryId) .Include(x => x.Role) .Include(x => x.UserAuthInfo) .ToListAsync(); for (int i = 0; i < userRoleListT.Count(); i++) { StaffVM staff = outputList.Where(x => x.Id == userRoleListT.ElementAt(i).UserAuthInfo.UserId).FirstOrDefault(); if (staff != null) { staff.Role = userRoleListT.ElementAt(i).Role.Name; staff.UserName = userRoleListT.ElementAt(i).UserAuthInfo.UserName; } } if (!string.IsNullOrEmpty(dataListVM.GlobalFilter) && !string.IsNullOrWhiteSpace(dataListVM.GlobalFilter)) { outputList = outputList.Where(output => output.AlternateCellNo != null ? output.AlternateCellNo.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false || output.CellNo != null ? output.CellNo.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false || output.Email != null ? output.Email.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false || output.Name != null ? output.Name.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false || output.PermanentAddress != null ? output.PermanentAddress.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false || output.PresentAddress != null ? output.PresentAddress.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false).ToList(); } outputList = outputList.Skip((dataListVM.PageNumber - 1) * dataListVM.PageSize).Take(dataListVM.PageSize).ToList(); var data = new WrapperStaffListVM(); data.ListOfData = outputList; data.TotalRecords = noOfRecordTask; this._utilService.Log("Successful In Getting Data"); if (withHistory) { data = await SetHistoryOverview(data, dataListVM.FactoryId); } return(data); }
public async Task <InitialLoadDataVM> GetStaffInitialData(GetDataListVM getDataListVM) { InitialLoadDataVM vm = new InitialLoadDataVM(); Task <WrapperRoleListVM> roleListTask = _serviceWrapper.RoleService.GetListPaged(getDataListVM); await Task.WhenAll(roleListTask); vm.RoleVMs = roleListTask.Result.ListOfData; return(vm); }
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 <WrapperPurchaseListVM> GetAllPurchaseAsync(GetDataListVM getDataListVM) { WrapperPurchaseListVM vm = new WrapperPurchaseListVM(); List <PurchaseVM> vmList = new List <PurchaseVM>(); Task <List <Invoice> > invoicesT = _repositoryWrapper .Invoice .FindAll() .Include(x => x.Supplier) .Include(x => x.InvoiceType) .Where(x => x.FactoryId == getDataListVM.FactoryId && x.InvoiceType.Name == TypeInvoice.Purchase.ToString()) .Skip((getDataListVM.PageNumber - 1) * (getDataListVM.PageSize)) .Take(getDataListVM.PageSize) .ToListAsync(); Task <List <Purchase> > purchasesT = _repositoryWrapper .Purchase .FindAll() .Where(x => x.FactoryId == getDataListVM.FactoryId) .Include(x => x.Item) .ThenInclude(s => s.ItemCategory) .ToListAsync(); await Task.WhenAll(invoicesT, purchasesT); List <Purchase> dbListPurchase = purchasesT.Result.ToList(); vmList = _utilService.Mapper.Map <List <Invoice>, List <PurchaseVM> >(invoicesT.Result.ToList()); List <Purchase> temp = new List <Purchase>(); for (int i = 0; i < vmList.Count; i++) { temp = dbListPurchase.Where(x => x.InvoiceId == vmList.ElementAt(i).InvoiceId).ToList(); vmList.ElementAt(i).ItemList = _utilService.Mapper.Map <List <Purchase>, List <PurchaseItemVM> >(temp); } vm.ListOfData = vmList; vm.TotalRecords = invoicesT.Result.ToList().Count; return(vm); }
public async Task <WrapperListCustomerVM> Update(string id, CustomerVM updateCustomerViewModel) { if (id != updateCustomerViewModel.CustomerId) { new WrapperListCustomerVM(); } Task <IEnumerable <Customer> > CustomersDB = _repositoryWrapper.Customer.FindByConditionAsync(x => x.Id == id && x.FactoryId == updateCustomerViewModel.FactoryId); //Task<IEnumerable<Address>> AddressesDB = _repositoryWrapper.Address.FindByConditionAsync(x => x.RelatedId == id && x.FactoryId == updateCustomerViewModel.FactoryId); //Task<IEnumerable<Phone>> PhonesDB = _repositoryWrapper.Phone.FindByConditionAsync(x => x.RelatedId == id && x.FactoryId == updateCustomerViewModel.FactoryId); await Task.WhenAll(CustomersDB); var CustomerUpdated = _utilService.GetMapper().Map <CustomerVM, Customer>(updateCustomerViewModel, CustomersDB.Result.ToList().FirstOrDefault()); //var AddressUpdated = _mapper.Map<UpdateCustomerViewModel, Address>(updateCustomerViewModel, AddressesDB.Result.ToList().FirstOrDefault()); //var PhoneUpdated = _mapper.Map<UpdateCustomerViewModel, Phone>(updateCustomerViewModel, PhonesDB.Result.ToList().FirstOrDefault()); _repositoryWrapper.Customer.Update(CustomerUpdated); //_repositoryWrapper.Address.Update(AddressUpdated); //_repositoryWrapper.Phone.Update(PhoneUpdated); Task <int> t1 = _repositoryWrapper.Customer.SaveChangesAsync(); //Task<int> t2 = _repositoryWrapper.Address.SaveChangesAsync(); //Task<int> t3 = _repositoryWrapper.Phone.SaveChangesAsync(); await Task.WhenAll(t1); this._utilService.Log("Successful In saving"); var dataParam = new GetDataListVM() { FactoryId = updateCustomerViewModel.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperListCustomerVM 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); }
// Stock -- decrease // StockIn -- not // Payable -- // Production public async Task <WrapperProductionListVM> AddProductions(List <AddProductionVM> vmList) { for (int i = 0; i < vmList.Count; i++) { await AddSingleProduction(vmList.ElementAt(i)); Console.WriteLine("dd"); } var dataParam = new GetDataListVM() { FactoryId = vmList.ElementAt(0).FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperProductionListVM data = await GetListPaged(dataParam); return(data); }
public async Task <InitialLoadDataVM> GetSalesInitialData(GetDataListVM getDataListVM) { InitialLoadDataVM vm = new InitialLoadDataVM(); Task <WrapperItemListVM> itemListTask = _serviceWrapper.ItemService.GetListPaged(getDataListVM); Task <WrapperItemCategoryListVM> itemCategoryListTask = _serviceWrapper.ItemCategoryService.GetListPaged(getDataListVM); Task <WrapperListCustomerVM> customerListTask = _serviceWrapper.CustomerService.GetListPaged(getDataListVM, false); Task <WrapperIncomeTypeListVM> incomeTypeListTask = _serviceWrapper.IncomeTypeService.GetListPaged(getDataListVM); Task <WrapperItemStatusListVM> itemStatusListTask = _serviceWrapper.ItemStatusService.GetListPaged(getDataListVM); Task <WrapperInvoiceTypeListVM> invoiceTypeListTask = _serviceWrapper.InvoiceTypeService.GetListPaged(getDataListVM); await Task.WhenAll(itemListTask, itemCategoryListTask, customerListTask, incomeTypeListTask, itemStatusListTask, invoiceTypeListTask); vm.ItemCategoryVMs = itemCategoryListTask.Result.ListOfData; vm.ItemVMs = itemListTask.Result.ListOfData; vm.CustomerVMs = customerListTask.Result.ListOfData; vm.IncomeTypeVMs = incomeTypeListTask.Result.ListOfData; vm.ItemStatusVMs = itemStatusListTask.Result.ListOfData; vm.InvoiceTypeVMs = invoiceTypeListTask.Result.ListOfData; return(vm); }
public async Task <WrapperFactoryListVM> Update(string id, FactoryVM vm) { IEnumerable <Factory> ItemDB = await _repositoryWrapper.Factory.FindByConditionAsync(x => x.Id == id); var ItemUpdated = _utilService.GetMapper().Map <FactoryVM, Factory>(vm, ItemDB.ToList().FirstOrDefault()); _repositoryWrapper.Factory.Update(ItemUpdated); await _repositoryWrapper.Factory.SaveChangesAsync(); var dataParam = new GetDataListVM() { FactoryId = vm.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperFactoryListVM data = await GetListPaged(dataParam); 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 <WrapperIncomeListVM> Delete(IncomeVM itemTemp) { Task <IEnumerable <Income> > incomeTask = _repositoryWrapper.Income.FindByConditionAsync(x => x.Id == itemTemp.Id && x.FactoryId == itemTemp.FactoryId); Task <IEnumerable <TblTransaction> > transactionTask = _repositoryWrapper.Transaction.FindByConditionAsync(x => x.InvoiceId == itemTemp.InvoiceId && x.FactoryId == itemTemp.FactoryId); Task <IEnumerable <Invoice> > invoiceTask = _repositoryWrapper.Invoice.FindByConditionAsync(x => x.Id == itemTemp.InvoiceId && x.FactoryId == itemTemp.FactoryId); await Task.WhenAll(incomeTask, transactionTask, invoiceTask); var incomeToDelete = incomeTask.Result.ToList().FirstOrDefault(); var transactionToDelete = transactionTask.Result.ToList().FirstOrDefault(); var invoiceToDelete = invoiceTask.Result.ToList().FirstOrDefault(); //if (item == null) //{ // return new WrapperIncomeListVM(); //} _repositoryWrapper.Income.Delete(incomeToDelete); _repositoryWrapper.Transaction.Delete(transactionToDelete); _repositoryWrapper.Invoice.Delete(invoiceToDelete); await _repositoryWrapper.Income.SaveChangesAsync(); await _repositoryWrapper.Transaction.SaveChangesAsync(); await _repositoryWrapper.Invoice.SaveChangesAsync(); var dataParam = new GetDataListVM() { FactoryId = itemTemp.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperIncomeListVM 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); }
public async Task <WrapperItemListVM> Update(string id, ItemVM vm) { IEnumerable <Item> ItemDB = await _repositoryWrapper.Item.FindByConditionAsync(x => x.Id == id && x.FactoryId == vm.FactoryId); var ItemUpdated = _utilService.GetMapper().Map <ItemVM, Item>(vm, ItemDB.ToList().FirstOrDefault()); _repositoryWrapper.Item.Update(ItemUpdated); await _repositoryWrapper.Item.SaveChangesAsync(); this._utilService.LogInfo("Successful In Updating Item"); var dataParam = new GetDataListVM() { FactoryId = vm.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperItemListVM data = await GetListPaged(dataParam); return(data); }
// 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 <WrapperItemListVM> Add(ItemVM vm) { var entityToAdd = _utilService.GetMapper().Map <ItemVM, Item>(vm); //string uniqueIdTask = await _repositoryWrapper.Item.GetUniqueId(); //entityToAdd.UniqueId = uniqueIdTask; entityToAdd = _repositoryWrapper.Item.Create(entityToAdd); await _repositoryWrapper.Item.SaveChangesAsync(); this._utilService.LogInfo("Successful In saving Item"); var dataParam = new GetDataListVM() { FactoryId = vm.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperItemListVM data = await GetListPaged(dataParam); return(data); }
public async Task <WrapperFactoryListVM> GetListPaged(GetDataListVM dataListVM) { var itemList = await _repositoryWrapper.Factory .FindAll() //.Where(x => x.FactoryId == dataListVM.FactoryId) .OrderByDescending(x => x.UpdatedDateTime) .Skip((dataListVM.PageNumber - 1) * (dataListVM.PageSize)) .Take(dataListVM.PageSize) .ToListAsync(); var dataRowCount = await _repositoryWrapper.Factory.NumOfRecord(); List <FactoryVM> itemVMLists = new List <FactoryVM>(); itemVMLists = this._utilService.Mapper.Map <List <Factory>, List <FactoryVM> >(itemList); var wrapper = new WrapperFactoryListVM() { ListOfData = itemVMLists, TotalRecords = dataRowCount }; return(wrapper); }
public async Task <WrapperSupplierListVM> GetListPaged(GetDataListVM dataListVM, bool withHistory) { IEnumerable <Supplier> ListTask = await _repositoryWrapper.Supplier.FindByConditionAsync(x => x.FactoryId == dataListVM.FactoryId); long noOfRecordTask = await _repositoryWrapper.Supplier.NumOfRecord(); List <Supplier> List = ListTask.ToList().OrderByDescending(x => x.UpdatedDateTime).ToList();//.Skip((dataListVM.PageNumber - 1) * dataListVM.PageSize).Take(dataListVM.PageSize).OrderByDescending(x => x.CreatedDateTime).ToList(); List <SupplierVM> outputList = new List <SupplierVM>(); outputList = _utilService.GetMapper().Map <List <Supplier>, List <SupplierVM> >(List); if (!string.IsNullOrEmpty(dataListVM.GlobalFilter) && !string.IsNullOrWhiteSpace(dataListVM.GlobalFilter)) { outputList = outputList.Where(output => output.AlternateCellNo != null ? output.AlternateCellNo.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false || output.CellNo != null ? output.CellNo.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false || output.Email != null ? output.Email.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false || output.Name != null ? output.Name.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false || output.PermanentAddress != null ? output.PermanentAddress.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false || output.PresentAddress != null ? output.PresentAddress.Contains(dataListVM.GlobalFilter, StringComparison.OrdinalIgnoreCase) : false).ToList(); } outputList = outputList.Skip((dataListVM.PageNumber - 1) * dataListVM.PageSize).Take(dataListVM.PageSize).ToList(); var data = new WrapperSupplierListVM(); data.ListOfData = outputList; data.TotalRecords = noOfRecordTask; this._utilService.Log("Successful In Getting Data"); if (withHistory) { data = await SetHistoryOverview(data, dataListVM.FactoryId); } return(data); }
public async Task <WrapperItemListVM> Delete(ItemVM itemTemp) { var itemTask = await _repositoryWrapper.Item.FindByConditionAsync(x => x.Id == itemTemp.Id && x.FactoryId == itemTemp.FactoryId); var item = itemTask.ToList().FirstOrDefault(); if (item == null) { return(new WrapperItemListVM()); } _repositoryWrapper.Item.Delete(item); await _repositoryWrapper.Item.SaveChangesAsync(); var dataParam = new GetDataListVM() { FactoryId = itemTemp.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperItemListVM data = await GetListPaged(dataParam); return(data); }