コード例 #1
0
        public async Task <WrapperSupplierListVM> Update(string id, SupplierVM ViewModel)
        {
            if (id != ViewModel.Id)
            {
                new WrapperSupplierListVM();
            }

            Task <IEnumerable <Supplier> > itemsDB = _repositoryWrapper.Supplier.FindByConditionAsync(x => x.Id == id && x.FactoryId == ViewModel.FactoryId);
            await Task.WhenAll(itemsDB);

            var itemUpdated = _utilService.GetMapper().Map <SupplierVM, Supplier>(ViewModel, itemsDB.Result.ToList().FirstOrDefault());

            _repositoryWrapper.Supplier.Update(itemUpdated);

            Task <int> t1 = _repositoryWrapper.Supplier.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
            };
            WrapperSupplierListVM data = await GetListPaged(dataParam, true);

            return(data);
        }
コード例 #2
0
        private async Task <WrapperSupplierListVM> SetHistoryOverview(WrapperSupplierListVM vm, string FactoryId)
        {
            var data = new GetDataListHistory();

            //Task<WrapperSupplierHistory>[] listOftask = new Task<WrapperSupplierHistory>[vm.ListOfData.Count];
            WrapperSupplierHistory[] listOftask = new WrapperSupplierHistory[vm.ListOfData.Count];
            for (int i = 0; i < vm.ListOfData.Count; i++)
            {
                SupplierVM temp = vm.ListOfData.ElementAt(i);
                data.ClientId   = temp.Id;
                data.PageNumber = -1;
                data.PageSize   = -1;
                data.FactoryId  = FactoryId;
                listOftask[i]   = await GetSupplierHistory(data);

                int len = listOftask[i].ListOfData.Count - 1;
                vm.ListOfData.ElementAt(i).PaidAmount       = listOftask[i].ListOfData[len].PaidAmount;
                vm.ListOfData.ElementAt(i).RecievableAmount = listOftask[i].ListOfData[len].RecievableAmount;
                vm.ListOfData.ElementAt(i).RecievedAmount   = listOftask[i].ListOfData[len].RecievedAmount;
                vm.ListOfData.ElementAt(i).PayableAmount    = listOftask[i].ListOfData[len].PayableAmount;
            }

            // await Task.WhenAll(listOftask);

            //for (int i = 0; i < vm.ListOfData.Count; i++)
            //{
            //    //SupplierHistory te = GetSupplierHistoryOverview(listOftask[i].Result);
            //    SupplierHistory te = GetSupplierHistoryOverview(listOftask[i]);
            //    vm.ListOfData.ElementAt(i).PaidAmount = te.PaidAmount;
            //    vm.ListOfData.ElementAt(i).RecievableAmount = te.RecievableAmount;
            //    vm.ListOfData.ElementAt(i).RecievedAmount = te.RecievedAmount;
            //    vm.ListOfData.ElementAt(i).PayableAmount = te.PayableAmount;
            //}
            return(vm);
        }
コード例 #3
0
        public async Task <WrapperSupplierListVM> Delete(SupplierVM Temp)
        {
            var Task = await _repositoryWrapper.Supplier.FindByConditionAsync(x => x.Id == Temp.Id && x.FactoryId == Temp.FactoryId);

            var datarow = Task.ToList().FirstOrDefault();

            if (datarow == null)
            {
                return(new WrapperSupplierListVM());
            }
            _repositoryWrapper.Supplier.Delete(datarow);
            await _repositoryWrapper.Supplier.SaveChangesAsync();

            this._utilService.Log("Successful In Deleting Data");
            var dataParam = new GetDataListVM()
            {
                FactoryId  = Temp.FactoryId,
                PageNumber = 1,
                PageSize   = 10,
                TotalRows  = 0
            };
            WrapperSupplierListVM data = await GetListPaged(dataParam, true);

            return(data);
        }
コード例 #4
0
        public async Task <ActionResult <WrapperSupplierListVM> > DeleteSupplier([FromBody] SupplierVM Temp)
        {
            WrapperSupplierListVM vb = new WrapperSupplierListVM();

            vb = await _serviceWrapper.SupplierService.Delete(Temp);

            _utilService.Log("Supplier Successfully Deleted");
            return(vb);
        }
コード例 #5
0
        public async Task <ActionResult <WrapperSupplierListVM> > AddSupplier([FromBody] SupplierVM VM)
        {
            WrapperSupplierListVM result = new WrapperSupplierListVM();

            result = await _serviceWrapper.SupplierService.Add(VM);

            _utilService.Log("Supplier Successfully Added");
            return(Ok(result));
        }
コード例 #6
0
        public async Task <ActionResult <WrapperSupplierListVM> > UpdateSupplier(string id, [FromBody] SupplierVM temp)
        {
            WrapperSupplierListVM result = new WrapperSupplierListVM();

            result = await _serviceWrapper.SupplierService.Update(id, temp);

            _utilService.Log("Supplier Successfully Updated");
            return(Ok(result));
        }
コード例 #7
0
        public async Task <WrapperSupplierListVM> Add(SupplierVM ViewModel)
        {
            var itemToAdd = _utilService.GetMapper().Map <SupplierVM, Supplier>(ViewModel);

            itemToAdd = _repositoryWrapper.Supplier.Create(itemToAdd);
            Task <int> t1 = _repositoryWrapper.Supplier.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
            };
            WrapperSupplierListVM data = await GetListPaged(dataParam, true);

            return(data);
        }
コード例 #8
0
        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);
        }