Beispiel #1
0
        public ReadResponse <MachineSpinningModel> Read(int page, int size, string order, List <string> select, string keyword, string filter)
        {
            IQueryable <MachineSpinningModel> Query = _DbSet.Include(x => x.Types);

            Query = Query
                    .Select(s => new MachineSpinningModel
            {
                Id               = s.Id,
                _CreatedBy       = s._CreatedBy,
                _CreatedUtc      = s._CreatedUtc,
                Code             = s.Code,
                _LastModifiedUtc = s._LastModifiedUtc,
                CapacityPerHour  = s.CapacityPerHour,
                Condition        = s.Condition,
                Delivery         = s.Delivery,
                CounterCondition = s.CounterCondition,
                Brand            = s.Brand,
                No               = s.No,
                Name             = s.Name,
                //Type = s.Type,
                Year        = s.Year,
                Line        = s.Line,
                UomId       = s.UomId,
                UnitCode    = s.UnitCode,
                UnitId      = s.UnitId,
                UnitName    = s.UnitName,
                UomUnit     = s.UomUnit,
                MachineCode = s.MachineCode,
                Types       = s.Types
            });

            List <string> searchAttributes = new List <string>()
            {
                "Brand", "Name", "No", "UnitName"
            };

            //Query = QueryHelper<MachineSpinningModel>.Search(Query, searchAttributes, keyword);
            if (keyword != null)
            {
                var machineSpinningTypes = _DbContext.MachineSpinningProcessType.Where(x => x.Type.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0).Select(x => x.MachineSpinningId).Distinct().ToList();
                Query = Query.Where(x => machineSpinningTypes.Contains(x.Id) ||
                                    x.Brand.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0 ||
                                    x.Name.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0 ||
                                    x.No.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0 ||
                                    x.UnitName.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0);
            }
            Dictionary <string, object> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(filter);

            Query = QueryHelper <MachineSpinningModel> .Filter(Query, FilterDictionary);

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(order);

            if (OrderDictionary.Count.Equals(0))
            {
                Query = Query.OrderBy(x => x.MachineCode).ThenBy(x => x.Line).ThenBy(x => x.No);
            }
            else
            {
                Query = QueryHelper <MachineSpinningModel> .Order(Query, OrderDictionary);
            }


            Pageable <MachineSpinningModel> pageable = new Pageable <MachineSpinningModel>(Query, page - 1, size);
            List <MachineSpinningModel>     Data     = pageable.Data.ToList();

            List <MachineSpinningModel> list = new List <MachineSpinningModel>();

            list.AddRange(
                Data.Select(s => new MachineSpinningModel
            {
                Id               = s.Id,
                _CreatedBy       = s._CreatedBy,
                _CreatedUtc      = s._CreatedUtc,
                Code             = s.Code,
                _LastModifiedUtc = s._LastModifiedUtc,
                CapacityPerHour  = s.CapacityPerHour,
                Condition        = s.Condition,
                Delivery         = s.Delivery,
                CounterCondition = s.CounterCondition,
                Brand            = s.Brand,
                Name             = s.Name,
                No               = s.No,
                //Type = s.Type,
                Year        = s.Year,
                Line        = s.Line,
                UnitCode    = s.UnitCode,
                UnitId      = s.UnitId,
                UnitName    = s.UnitName,
                UomId       = s.UomId,
                UomUnit     = s.UomUnit,
                MachineCode = s.MachineCode,
                Types       = s.Types
            }).ToList()
                );

            int TotalData = pageable.TotalCount;

            return(new ReadResponse <MachineSpinningModel>(list, TotalData, OrderDictionary, new List <string>()));
        }
        public Tuple <List <GarmentInternalPurchaseOrderExternalPurchaseOrderDurationReportViewModel>, int> GetIPOEPODurationReport(string unit, string duration, DateTime?dateFrom, DateTime?dateTo, int page, int size, string Order, int offset)
        {
            var Query = GetIPOEPODurationReportQuery(unit, duration, dateFrom, dateTo, offset);

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Order);

            if (OrderDictionary.Count.Equals(0))
            {
                Query = Query.OrderByDescending(b => b.poIntCreatedDate);
            }
            //else
            //{
            //    string Key = OrderDictionary.Keys.First();
            //    string OrderType = OrderDictionary[Key];

            //    Query = Query.OrderBy(string.Concat(Key, " ", OrderType));
            //}

            Pageable <GarmentInternalPurchaseOrderExternalPurchaseOrderDurationReportViewModel> pageable = new Pageable <GarmentInternalPurchaseOrderExternalPurchaseOrderDurationReportViewModel>(Query, page - 1, size);
            List <GarmentInternalPurchaseOrderExternalPurchaseOrderDurationReportViewModel>     Data     = pageable.Data.ToList <GarmentInternalPurchaseOrderExternalPurchaseOrderDurationReportViewModel>();
            int TotalData = pageable.TotalCount;

            return(Tuple.Create(Data, TotalData));
        }
        public Tuple <List <CategoryViewModel>, int, Dictionary <string, string> > JoinDivision(int Page = 1, int Size = 25, string Order = "{}", string Keyword = "", string Filter = "{}")
        {
            //IQueryable<Category> Query = this.DbContext.Categories;
            //IQueryable<Division> divisions = DbContext.Divisions;

            var Query = from t1 in DbContext.Categories
                        from t2 in DbContext.Divisions
                        where ((!string.IsNullOrEmpty(t1.Name) && t1.Name.IndexOf(Keyword, StringComparison.OrdinalIgnoreCase) >= 0) ||
                               (!string.IsNullOrEmpty(t2.Name) && t2.Name.IndexOf(Keyword, StringComparison.OrdinalIgnoreCase) >= 0))
                        select new CategoryViewModel()
            {
                code            = t1.Code,
                codeRequirement = t1.CodeRequirement,
                divisionId      = t2.Id,
                divisionName    = t2.Name,
                name            = t1.Name,
                UId             = t1.UId,
                _id             = t1.Id,
                _updatedDate    = t1._LastModifiedUtc
            };
            Dictionary <string, object> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(Filter);

            if (FilterDictionary != null && !FilterDictionary.Count.Equals(0))
            {
                foreach (var f in FilterDictionary)
                {
                    string Key         = f.Key;
                    object Value       = f.Value;
                    string filterQuery = string.Concat(string.Empty, Key, " == @0");

                    Query = Query.Where(filterQuery, Value);
                }
            }
            //qu = ConfigureFilter(Query, FilterDictionary);
            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Order);

            ///* Search With Keyword */
            //if (Keyword != null)
            //{
            //    List<string> SearchAttributes = new List<string>()
            //    {
            //        "Code", "Name"
            //    };

            //    Query = Query.Where(General.BuildSearch(SearchAttributes), Keyword);
            //}

            ///* Const Select */
            //List<string> SelectedFields = new List<string>()
            //{
            //    "_id", "code", "name"
            //};

            //Query = Query
            //    .Select(b => new Category
            //    {
            //        Id = b.Id,
            //        Code = b.Code,
            //        Name = b.Name
            //    });

            /* Order */
            if (OrderDictionary.Count.Equals(0))
            {
                OrderDictionary.Add("_updatedDate", General.DESCENDING);

                Query = Query.OrderByDescending(b => b._updatedDate); /* Default Order */
            }
            else
            {
                string Key          = OrderDictionary.Keys.First();
                string OrderType    = OrderDictionary[Key];
                string TransformKey = General.TransformOrderBy(Key);

                BindingFlags IgnoreCase = BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance;

                Query = OrderType.Equals(General.ASCENDING) ?
                        Query.OrderBy(b => b.GetType().GetProperty(TransformKey, IgnoreCase).GetValue(b)) :
                        Query.OrderByDescending(b => b.GetType().GetProperty(TransformKey, IgnoreCase).GetValue(b));
            }

            /* Pagination */
            Pageable <CategoryViewModel> pageable = new Pageable <CategoryViewModel>(Query, Page - 1, Size);
            List <CategoryViewModel>     Data     = pageable.Data.ToList <CategoryViewModel>();

            int TotalData = pageable.TotalCount;

            return(Tuple.Create(Data, TotalData, OrderDictionary));
        }
Beispiel #4
0
        public Tuple <List <UnitPaymentCorrectionNote>, int, Dictionary <string, string> > Read(int Page = 1, int Size = 25, string Order = "{}", string Keyword = null, string Filter = "{}")
        {
            IQueryable <UnitPaymentCorrectionNote> Query = this.dbSet;

            Query = Query
                    .Select(s => new UnitPaymentCorrectionNote
            {
                Id                    = s.Id,
                UPCNo                 = s.UPCNo,
                CorrectionDate        = s.CorrectionDate,
                CorrectionType        = s.CorrectionType,
                UPOId                 = s.UPOId,
                UPONo                 = s.UPONo,
                SupplierCode          = s.SupplierCode,
                SupplierName          = s.SupplierName,
                InvoiceCorrectionNo   = s.InvoiceCorrectionNo,
                InvoiceCorrectionDate = s.InvoiceCorrectionDate,
                useVat                = s.useVat,
                useIncomeTax          = s.useIncomeTax,
                ReleaseOrderNoteNo    = s.ReleaseOrderNoteNo,
                DueDate               = s.DueDate,
                Items                 = s.Items.Select(
                    q => new UnitPaymentCorrectionNoteItem
                {
                    Id          = q.Id,
                    UPCId       = q.UPCId,
                    UPODetailId = q.UPODetailId,
                    URNNo       = q.URNNo,
                    EPONo       = q.EPONo,
                    PRId        = q.PRId,
                    PRNo        = q.PRNo,
                    PRDetailId  = q.PRDetailId,
                }
                    )
                                        .ToList(),
                CreatedBy       = s.CreatedBy,
                LastModifiedUtc = s.LastModifiedUtc
            }).Where(k => k.CorrectionType == "Jumlah")
                    .OrderByDescending(j => j.LastModifiedUtc);

            List <string> searchAttributes = new List <string>()
            {
                "UPCNo", "UPONo", "SupplierName", "InvoiceCorrectionNo"
            };

            Query = QueryHelper <UnitPaymentCorrectionNote> .ConfigureSearch(Query, searchAttributes, Keyword);

            Dictionary <string, string> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Filter);

            Query = QueryHelper <UnitPaymentCorrectionNote> .ConfigureFilter(Query, FilterDictionary);

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Order);

            Query = QueryHelper <UnitPaymentCorrectionNote> .ConfigureOrder(Query, OrderDictionary);

            Pageable <UnitPaymentCorrectionNote> pageable = new Pageable <UnitPaymentCorrectionNote>(Query, Page - 1, Size);
            List <UnitPaymentCorrectionNote>     Data     = pageable.Data.ToList <UnitPaymentCorrectionNote>();
            int TotalData = pageable.TotalCount;

            return(Tuple.Create(Data, TotalData, OrderDictionary));
        }
        public Tuple <List <PurchasingDisposition>, int, Dictionary <string, string> > Read(int Page = 1, int Size = 25, string Order = "{}", string Keyword = null, string Filter = "{}")
        {
            IQueryable <PurchasingDisposition> Query = this.dbSet;

            List <string> searchAttributes = new List <string>()
            {
                "DispositionNo", "SupplierName", "CurrencyCode", "DivisionName", "CategoryName"
            };

            Query = QueryHelper <PurchasingDisposition> .ConfigureSearch(Query, searchAttributes, Keyword);

            Dictionary <string, string> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Filter);

            Query = QueryHelper <PurchasingDisposition> .ConfigureFilter(Query, FilterDictionary);

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Order);

            Query = QueryHelper <PurchasingDisposition> .ConfigureOrder(Query, OrderDictionary);

            Query = Query
                    .Select(s => new PurchasingDisposition
            {
                DispositionNo       = s.DispositionNo,
                Id                  = s.Id,
                SupplierCode        = s.SupplierCode,
                SupplierId          = s.SupplierId,
                SupplierName        = s.SupplierName,
                Bank                = s.Bank,
                CurrencyCode        = s.CurrencyCode,
                CurrencyId          = s.CurrencyId,
                CurrencyRate        = s.CurrencyRate,
                ConfirmationOrderNo = s.ConfirmationOrderNo,
                //InvoiceNo = s.InvoiceNo,
                PaymentMethod   = s.PaymentMethod,
                PaymentDueDate  = s.PaymentDueDate,
                CreatedBy       = s.CreatedBy,
                LastModifiedUtc = s.LastModifiedUtc,
                CreatedUtc      = s.CreatedUtc,
                Amount          = s.Amount,
                Calculation     = s.Calculation,
                //Investation = s.Investation,
                Position          = s.Position,
                ProformaNo        = s.ProformaNo,
                Remark            = s.Remark,
                UId               = s.UId,
                CategoryCode      = s.CategoryCode,
                CategoryId        = s.CategoryId,
                CategoryName      = s.CategoryName,
                DPP               = s.DPP,
                IncomeTaxValue    = s.IncomeTaxValue,
                VatValue          = s.VatValue,
                IncomeTaxBy       = s.IncomeTaxBy,
                DivisionCode      = s.DivisionCode,
                DivisionId        = s.DivisionId,
                DivisionName      = s.DivisionName,
                PaymentCorrection = s.PaymentCorrection,
                Items             = s.Items.Select(x => new PurchasingDispositionItem()
                {
                    EPOId         = x.EPOId,
                    EPONo         = x.EPONo,
                    Id            = x.Id,
                    IncomeTaxId   = x.IncomeTaxId,
                    IncomeTaxName = x.IncomeTaxName,
                    IncomeTaxRate = x.IncomeTaxRate,
                    UseVat        = x.UseVat,
                    UseIncomeTax  = x.UseIncomeTax,
                    UId           = x.UId,

                    Details = x.Details.Select(y => new PurchasingDispositionDetail()
                    {
                        UId = y.UId,

                        DealQuantity                = y.DealQuantity,
                        DealUomId                   = y.DealUomId,
                        DealUomUnit                 = y.DealUomUnit,
                        Id                          = y.Id,
                        PaidPrice                   = y.PaidPrice,
                        PaidQuantity                = y.PaidQuantity,
                        PricePerDealUnit            = y.PricePerDealUnit,
                        PriceTotal                  = y.PriceTotal,
                        PRId                        = y.PRId,
                        PRNo                        = y.PRNo,
                        ProductCode                 = y.ProductCode,
                        ProductId                   = y.ProductId,
                        ProductName                 = y.ProductName,
                        PurchasingDispositionItem   = y.PurchasingDispositionItem,
                        PurchasingDispositionItemId = y.PurchasingDispositionItemId,
                        UnitCode                    = y.UnitCode,
                        UnitId                      = y.UnitId,
                        UnitName                    = y.UnitName
                    }).ToList()
                }).ToList()
            });
            Pageable <PurchasingDisposition> pageable = new Pageable <PurchasingDisposition>(Query, Page - 1, Size);
            List <PurchasingDisposition>     Data     = pageable.Data.ToList <PurchasingDisposition>();
            int TotalData = pageable.TotalCount;

            return(Tuple.Create(Data, TotalData, OrderDictionary));
        }
Beispiel #6
0
        public override ReadResponse <ProductionOrderModel> Read(int page, int size, string order, List <string> select, string keyword, string filter)
        {
            IQueryable <ProductionOrderModel> Query = DbSet;

            List <string> SearchAttributes = new List <string>()
            {
                "OrderNo", "SalesContractNo", "BuyerType", "BuyerName", "ProcessTypeName", "MaterialName", "MaterialConstructionName", "MaterialWidth"
            };

            Query = QueryHelper <ProductionOrderModel> .Search(Query, SearchAttributes, keyword);

            Dictionary <string, object> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(filter);

            Query = QueryHelper <ProductionOrderModel> .Filter(Query, FilterDictionary);

            List <string> SelectedFields = new List <string>()
            {
                "Id", "POType", "Code", "Buyer", "ProcessType", "LastModifiedUtc", "FinishingPrintingSalesContract", "OrderNo", "Details", "OrderType", "HandlingStandard", "Material", "YarnMaterial", "DeliveryDate", "SalesContractNo", "MaterialConstruction", "FinishWidth", "DesignCode", "DesignNumber", "OrderQuantity", "Uom",
                "DistributedQuantity", "IsCompleted", "IsClosed", "IsCalculated", "Account", "MaterialWidth", "PackingInstruction", "MaterialOrigin"
            };

            Query = Query
                    .Select(field => new ProductionOrderModel
            {
                Id                       = field.Id,
                POType                   = field.POType,
                Code                     = field.Code,
                DeliveryDate             = field.DeliveryDate,
                HandlingStandard         = field.HandlingStandard,
                FinishWidth              = field.FinishWidth,
                MaterialId               = field.MaterialId,
                MaterialCode             = field.MaterialCode,
                MaterialName             = field.MaterialName,
                MaterialConstructionId   = field.MaterialConstructionId,
                MaterialConstructionCode = field.MaterialConstructionCode,
                MaterialConstructionName = field.MaterialConstructionName,
                SalesContractId          = field.SalesContractId,
                SalesContractNo          = field.SalesContractNo,
                BuyerType                = field.BuyerType,
                BuyerName                = field.BuyerName,
                IsCalculated             = field.IsCalculated,
                BuyerId                  = field.BuyerId,
                OrderNo                  = field.OrderNo,
                ProcessTypeId            = field.ProcessTypeId,
                ProcessTypeCode          = field.ProcessTypeCode,
                ProcessTypeName          = field.ProcessTypeName,
                UomId                    = field.UomId,
                MaterialWidth            = field.MaterialWidth,
                UomUnit                  = field.UomUnit,
                YarnMaterialId           = field.YarnMaterialId,
                YarnMaterialCode         = field.YarnMaterialCode,
                YarnMaterialName         = field.YarnMaterialName,
                OrderTypeId              = field.OrderTypeId,
                OrderTypeCode            = field.OrderTypeCode,
                OrderTypeName            = field.OrderTypeName,
                OrderQuantity            = field.OrderQuantity,
                LastModifiedUtc          = field.LastModifiedUtc,
                Details                  = field.Details,
                DesignCode               = field.DesignCode,
                DesignNumber             = field.DesignNumber,
                ProcessTypeSPPCode       = field.ProcessTypeSPPCode,
                ProcessTypeUnit          = field.ProcessTypeUnit,
                DistributedQuantity      = field.DistributedQuantity,
                IsCompleted              = field.IsCompleted,
                IsClosed                 = field.IsClosed,
                AccountId                = field.AccountId,
                AccountUserName          = field.AccountUserName,
                ProfileFirstName         = field.ProfileFirstName,
                ProfileGender            = field.ProfileGender,
                ProfileLastName          = field.ProfileLastName,
                PackingInstruction       = field.PackingInstruction,
                MaterialOrigin           = field.MaterialOrigin
            });

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(order);

            Query = QueryHelper <ProductionOrderModel> .Order(Query, OrderDictionary);

            Pageable <ProductionOrderModel> pageable = new Pageable <ProductionOrderModel>(Query, page - 1, size);
            List <ProductionOrderModel>     data     = pageable.Data.ToList <ProductionOrderModel>();
            int totalData = pageable.TotalCount;

            return(new ReadResponse <ProductionOrderModel>(data, totalData, OrderDictionary, SelectedFields));
        }
        public static void ToPageableGridSortingViewModel(IEnumerable <SortModel> source, Pageable <GridSortingViewModel> destination)
        {
            if (destination == null)
            {
                destination = new Pageable <GridSortingViewModel>();
            }

            foreach (var sortModel in source)
            {
                var gridSortingViewModel = new GridSortingViewModel();
                Map(sortModel, gridSortingViewModel);
                destination.Add(gridSortingViewModel);
            }
        }
Beispiel #8
0
        public IActionResult Get([FromQuery] Pageable pageable)
        {
            var result = _blockListRepository.GetBlockListByUserId(UserId, pageable);

            return(Ok(result));
        }
Beispiel #9
0
        public ReadResponse <KanbanModel> Read(int page, int size, string order, List <string> select, string keyword, string filter)
        {
            IQueryable <KanbanModel> query = DbSet;

            List <string> searchAttributes = new List <string>()
            {
                "Code", "ProductionOrderOrderNo", "CartCartNumber"
            };

            query = QueryHelper <KanbanModel> .Search(query, searchAttributes, keyword);

            object processFilterData = null;

            if (filter.Contains("CustomFilter#IntructionStepProcess"))
            {
                var processFilter = filter;

                Dictionary <string, object> processFilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(processFilter);

                foreach (var f in processFilterDictionary)
                {
                    string key   = f.Key;
                    object Value = f.Value;
                    //string filterQuery = Value;
                    processFilterData = Value;
                }

                filter = "{}";


                query = query
                        .Where(x => x.Instruction.Steps.Any(y => y.Process == processFilterData.ToString()));
            }

            Dictionary <string, object> filterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(filter);

            query = QueryHelper <KanbanModel> .Filter(query, filterDictionary);


            List <string> selectedFields = new List <string>()
            {
                "Id", "Code", "ProductionOrder", "CurrentStepIndex", "Cart", "Instruction", "SelectedProductionOrderDetail", "LastModifiedUtc", "OldKanbanId", "IsComplete", "IsInactive"
            };


            query = query
                    .Select(field => new KanbanModel
            {
                Id               = field.Id,
                Code             = field.Code,
                CartCartNumber   = field.CartCartNumber,
                CurrentStepIndex = field.CurrentStepIndex,
                CartQty          = field.CartQty,
                IsBadOutput      = field.IsBadOutput,
                IsComplete       = field.IsComplete,
                IsInactive       = field.IsInactive,
                IsReprocess      = field.IsReprocess,
                Instruction      = new KanbanInstructionModel()
                {
                    Id    = field.Instruction.Id,
                    Name  = field.Instruction.Name,
                    Steps = new List <KanbanStepModel>(field.Instruction.Steps.OrderBy(x => x.StepIndex).ThenBy(x => x.Id).Select(i => new KanbanStepModel()
                    {
                        Id            = i.Id,
                        Process       = i.Process,
                        ProcessArea   = i.ProcessArea,
                        SelectedIndex = i.SelectedIndex,
                        StepIndex     = i.StepIndex
                    }))
                },
                OldKanbanId                                = field.OldKanbanId,
                LastModifiedUtc                            = field.LastModifiedUtc,
                ProductionOrderMaterialName                = field.ProductionOrderMaterialName,
                ProductionOrderMaterialConstructionName    = field.ProductionOrderMaterialConstructionName,
                ProductionOrderYarnMaterialName            = field.ProductionOrderYarnMaterialName,
                FinishWidth                                = field.FinishWidth,
                ProductionOrderOrderNo                     = field.ProductionOrderOrderNo,
                SelectedProductionOrderDetailColorRequest  = field.SelectedProductionOrderDetailColorRequest,
                SelectedProductionOrderDetailColorTemplate = field.SelectedProductionOrderDetailColorTemplate,
                SelectedProductionOrderDetailColorTypeCode = field.SelectedProductionOrderDetailColorTypeCode,
                SelectedProductionOrderDetailColorTypeName = field.SelectedProductionOrderDetailColorTypeName,
                SelectedProductionOrderDetailId            = field.SelectedProductionOrderDetailId,
                SelectedProductionOrderDetailQuantity      = field.SelectedProductionOrderDetailQuantity,
                SelectedProductionOrderDetailUomUnit       = field.SelectedProductionOrderDetailUomUnit
            });



            Dictionary <string, string> orderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(order);

            query = QueryHelper <KanbanModel> .Order(query, orderDictionary);

            Pageable <KanbanModel> pageable = new Pageable <KanbanModel>(query, page - 1, size);
            List <KanbanModel>     data     = pageable.Data.ToList();
            int totalData = pageable.TotalCount;

            return(new ReadResponse <KanbanModel>(data, totalData, orderDictionary, selectedFields));
        }
        public override Tuple <List <BudgetCurrency>, int, Dictionary <string, string>, List <string> > ReadModel(int Page = 1, int Size = 25, string Order = "{}", List <string> Select = null, string Keyword = null, string Filter = "{}")
        {
            IQueryable <BudgetCurrency> Query           = this.DbContext.BudgetCurrencies;
            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Order);

            /* Search With Keyword */
            if (Keyword != null)
            {
                List <string> SearchAttributes = new List <string>()
                {
                    "Code"
                };

                Query = Query.Where(General.BuildSearch(SearchAttributes), Keyword);
            }

            /* Const Select */
            List <string> SelectedFields = new List <string>()
            {
                "Id", "code", "rate", "date", "remark"
            };

            Query = Query
                    .Select(g => new BudgetCurrency
            {
                Id     = g.Id,
                Code   = g.Code,
                Rate   = g.Rate,
                Date   = g.Date,
                Remark = g.Remark
            });

            /* Order */
            if (OrderDictionary.Count.Equals(0))
            {
                OrderDictionary.Add("_updatedDate", General.DESCENDING);

                Query = Query.OrderByDescending(b => b._LastModifiedUtc);                 /* Default Order */
            }
            else
            {
                string Key          = OrderDictionary.Keys.First();
                string OrderType    = OrderDictionary[Key];
                string TransformKey = General.TransformOrderBy(Key);

                BindingFlags IgnoreCase = BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance;

                Query = OrderType.Equals(General.ASCENDING) ?
                        Query.OrderBy(b => b.GetType().GetProperty(TransformKey, IgnoreCase).GetValue(b)) :
                        Query.OrderByDescending(b => b.GetType().GetProperty(TransformKey, IgnoreCase).GetValue(b));
            }



            /* Pagination */
            Pageable <BudgetCurrency> pageable = new Pageable <BudgetCurrency>(Query, Page - 1, Size);
            List <BudgetCurrency>     Data     = pageable.Data.ToList <BudgetCurrency>();

            int TotalData = pageable.TotalCount;

            return(Tuple.Create(Data, TotalData, OrderDictionary, SelectedFields));
        }
        public override Tuple <List <SpinningInputProduction>, int, Dictionary <string, string>, List <string> > ReadModel(int Page = 1, int Size = 25, string Order = "{}", List <string> Select = null, string Keyword = null, string Filter = "{}")
        {
            IQueryable <SpinningInputProduction> Query           = this.DbContext.WinderInputProductions;
            Dictionary <string, string>          OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Order);

            if (Keyword != null)
            {
                List <string> SearchAttributes = new List <string>()
                {
                    "NomorInputProduksi", "YarnName", "UnitName", "MachineName", "Lot"
                };

                Query = ConfigureSearch(Query, SearchAttributes, Keyword);
            }

            /* Const Select */
            List <string> SelectedFields = new List <string>()
            {
                "Id", "NomorInputProduksi", "Yarn", "Unit", "Machine", "Lot", "Shift", "Date", "Counter", "Hank", "Input"
            };

            Query = Query
                    .Select(o => new SpinningInputProduction
            {
                Id = o.Id,
                NomorInputProduksi = o.NomorInputProduksi,
                YarnId             = o.YarnId,
                YarnName           = o.YarnName,
                UnitId             = o.UnitId,
                UnitName           = o.UnitName,
                MachineId          = o.MachineId,
                MachineName        = o.MachineName,
                Lot     = o.Lot,
                Shift   = o.Shift,
                Date    = o.Date,
                Counter = o.Counter,
                Hank    = o.Hank,
                Ne      = o.Ne,
                Bale    = o.Bale,
            });

            /* Order */
            if (OrderDictionary.Count.Equals(0))
            {
                OrderDictionary.Add("_updatedDate", General.DESCENDING);

                Query = Query.OrderByDescending(b => b._LastModifiedUtc); /* Default Order */
            }
            else
            {
                string Key          = OrderDictionary.Keys.First();
                string OrderType    = OrderDictionary[Key];
                string TransformKey = General.TransformOrderBy(Key);

                BindingFlags IgnoreCase = BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance;

                Query = OrderType.Equals(General.ASCENDING) ?
                        Query.OrderBy(b => b.GetType().GetProperty(TransformKey, IgnoreCase).GetValue(b)) :
                        Query.OrderByDescending(b => b.GetType().GetProperty(TransformKey, IgnoreCase).GetValue(b));
            }

            //Dictionary<string, string> FilterDictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(Filter);
            //Query = ConfigureFilter(Query, FilterDictionary);

            /* Pagination */
            Pageable <SpinningInputProduction> pageable = new Pageable <SpinningInputProduction>(Query, Page - 1, Size);
            List <SpinningInputProduction>     Data     = pageable.Data.ToList <SpinningInputProduction>();

            int TotalData = pageable.TotalCount;

            return(Tuple.Create(Data, TotalData, OrderDictionary, SelectedFields));
        }
 /// <summary>
 /// Kullanıcıya ait mesaj listesi
 /// </summary>
 /// <param name="userId">Kullanıcı id</param>
 /// <param name="pageable">Sayfalama</param>
 /// <returns>Mesaj listesi</returns>
 public IPagedList <DirectMessageModel> GetDirectMessageByUserId(string userId, Pageable pageable)
 {
     return(Query()
            .Where(x => x.UserId == userId)
            .Select(model => _mapper.Map <DirectMessageModel>(model))
            .ToPagedList(pageable));
 }
        public ReadResponse <ShipmentDocumentModel> Read(int page, int size, string order, List <string> select, string keyword, string filter)
        {
            IQueryable <ShipmentDocumentModel> Query = _DbSet.Include(x => x.Details).ThenInclude(x => x.Items).ThenInclude(x => x.PackingReceiptItems);


            List <string> searchAttributes = new List <string>()
            {
                "Code", "BuyerCode", "BuyerName", "CreatedBy"
            };

            Query = QueryHelper <ShipmentDocumentModel> .Search(Query, searchAttributes, keyword);

            Dictionary <string, object> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(filter);

            Query = QueryHelper <ShipmentDocumentModel> .Filter(Query, FilterDictionary);

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(order);

            Query = QueryHelper <ShipmentDocumentModel> .Order(Query, OrderDictionary);

            Pageable <ShipmentDocumentModel> pageable = new Pageable <ShipmentDocumentModel>(Query, page - 1, size);
            List <ShipmentDocumentModel>     Data     = pageable.Data.ToList();

            List <ShipmentDocumentModel> list = new List <ShipmentDocumentModel>();

            list.AddRange(
                Data.Select(s => new ShipmentDocumentModel
            {
                Id              = s.Id,
                CreatedUtc      = s.CreatedUtc,
                CreatedBy       = s.CreatedBy,
                Code            = s.Code,
                LastModifiedUtc = s.LastModifiedUtc,
                DeliveryCode    = s.DeliveryCode,
                DeliveryDate    = s.DeliveryDate,
                BuyerId         = s.BuyerId,
                BuyerAddress    = s.BuyerAddress,
                BuyerNPWP       = s.BuyerNPWP,
                BuyerCode       = s.BuyerCode,
                BuyerName       = s.BuyerName,
                Details         = s.Details.Select(t => new ShipmentDocumentDetailModel
                {
                    Items = t.Items.Select(u => new ShipmentDocumentItemModel
                    {
                        PackingReceiptItems = u.PackingReceiptItems.Select(v => new ShipmentDocumentPackingReceiptItemModel
                        {
                            ProductName = v.ProductName,
                            ProductCode = v.ProductCode,
                            Quantity    = v.Quantity,
                            Weight      = v.Weight,
                            Length      = v.Length,
                            UOMId       = v.UOMId,
                            UOMUnit     = v.UOMUnit,
                        }).ToList(),
                    }).ToList(),
                }).ToList(),
            }).ToList()
                );

            int TotalData = pageable.TotalCount;

            return(new ReadResponse <ShipmentDocumentModel>(list, TotalData, OrderDictionary, new List <string>()));
        }
Beispiel #14
0
        public ReadResponse <MachineSpinningModel> ReadNoOnly(int page, int size, string order, List <string> select, string keyword, string filter)
        {
            IQueryable <MachineSpinningModel> Query = _DbSet.Include(x => x.Types);

            Query = Query
                    .Select(s => new MachineSpinningModel
            {
                Id               = s.Id,
                _CreatedBy       = s._CreatedBy,
                _CreatedUtc      = s._CreatedUtc,
                Code             = s.Code,
                _LastModifiedUtc = s._LastModifiedUtc,
                CapacityPerHour  = s.CapacityPerHour,
                Condition        = s.Condition,
                Delivery         = s.Delivery,
                CounterCondition = s.CounterCondition,
                Brand            = s.Brand,
                No               = s.No,
                Name             = s.Name,
                //Type = s.Type,
                Year        = s.Year,
                Line        = s.Line,
                UomId       = s.UomId,
                UnitCode    = s.UnitCode,
                UnitId      = s.UnitId,
                UnitName    = s.UnitName,
                UomUnit     = s.UomUnit,
                MachineCode = s.MachineCode,
                Types       = s.Types
            });

            List <string> searchAttributes = new List <string>()
            {
                "No"
            };

            Query = QueryHelper <MachineSpinningModel> .Search(Query, searchAttributes, keyword);

            Dictionary <string, object> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(filter);

            Query = QueryHelper <MachineSpinningModel> .Filter(Query, FilterDictionary);

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(order);

            Query = QueryHelper <MachineSpinningModel> .Order(Query, OrderDictionary);

            Pageable <MachineSpinningModel> pageable = new Pageable <MachineSpinningModel>(Query, page - 1, size);
            List <MachineSpinningModel>     Data     = pageable.Data.ToList();

            List <MachineSpinningModel> list = new List <MachineSpinningModel>();

            list.AddRange(
                Data.Select(s => new MachineSpinningModel
            {
                Id               = s.Id,
                _CreatedBy       = s._CreatedBy,
                _CreatedUtc      = s._CreatedUtc,
                Code             = s.Code,
                _LastModifiedUtc = s._LastModifiedUtc,
                CapacityPerHour  = s.CapacityPerHour,
                Condition        = s.Condition,
                Delivery         = s.Delivery,
                CounterCondition = s.CounterCondition,
                Brand            = s.Brand,
                Name             = s.Name,
                No               = s.No,
                //Type = s.Type,
                Year        = s.Year,
                Line        = s.Line,
                UnitCode    = s.UnitCode,
                UnitId      = s.UnitId,
                UnitName    = s.UnitName,
                UomId       = s.UomId,
                UomUnit     = s.UomUnit,
                MachineCode = s.MachineCode,
                Types       = s.Types
            }).ToList()
                );

            int TotalData = pageable.TotalCount;

            return(new ReadResponse <MachineSpinningModel>(Query.ToList(), TotalData, OrderDictionary, new List <string>()));
        }
        public override Tuple <List <AccountBank>, int, Dictionary <string, string>, List <string> > ReadModel(int Page = 1, int Size = 25, string Order = "{}", List <string> Select = null, string Keyword = null, string Filter = "{}")
        {
            IQueryable <AccountBank> Query = this.DbContext.AccountBanks;

            Dictionary <string, object> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(Filter);

            Query = ConfigureFilter(Query, FilterDictionary);

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Order);

            /* Search With Keyword */
            if (Keyword != null)
            {
                List <string> SearchAttributes = new List <string>()
                {
                    "BankName", "BankAddress", "AccountName", "AccountNumber", "BankCode"
                };

                Query = Query.Where(General.BuildSearch(SearchAttributes), Keyword);
            }

            /* Const Select */
            List <string> SelectedFields = new List <string>()
            {
                "Id", "Code", "BankCode", "BankName", "BankAddress", "AccountName", "AccountNumber", "SwiftCode", "Currency", "Division", "AccountCOA"
            };

            Query = Query
                    .Select(a => new AccountBank
            {
                Id               = a.Id,
                Code             = a.Code,
                BankCode         = a.BankCode,
                BankName         = a.BankName,
                BankAddress      = a.BankAddress,
                AccountName      = a.AccountName,
                AccountNumber    = a.AccountNumber,
                SwiftCode        = a.SwiftCode,
                CurrencyId       = a.CurrencyId,
                CurrencyCode     = a.CurrencyCode,
                DivisionCode     = a.DivisionCode,
                DivisionId       = a.DivisionId,
                DivisionName     = a.DivisionName,
                _LastModifiedUtc = a._LastModifiedUtc,
                AccountCOA       = a.AccountCOA
            });

            /* Order */
            if (OrderDictionary.Count.Equals(0))
            {
                OrderDictionary.Add("_LastModifiedUtc", General.DESCENDING);

                Query = Query.OrderByDescending(b => b._LastModifiedUtc); /* Default Order */
            }
            else
            {
                string Key          = OrderDictionary.Keys.First();
                string OrderType    = OrderDictionary[Key];
                string TransformKey = General.TransformOrderBy(Key);

                BindingFlags IgnoreCase = BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance;

                Query = OrderType.Equals(General.ASCENDING) ?
                        Query.OrderBy(b => b.GetType().GetProperty(TransformKey, IgnoreCase).GetValue(b)) :
                        Query.OrderByDescending(b => b.GetType().GetProperty(TransformKey, IgnoreCase).GetValue(b));
            }

            /* Pagination */
            Pageable <AccountBank> pageable = new Pageable <AccountBank>(Query, Page - 1, Size);
            List <AccountBank>     Data     = pageable.Data.ToList <AccountBank>();

            int TotalData = pageable.TotalCount;

            return(Tuple.Create(Data, TotalData, OrderDictionary, SelectedFields));
        }
        public ReadResponse <object> GetAllByPosition(int Page, int Size, string Order, string Keyword, string Filter)
        {
            var query = dbContext.PurchasingDocumentExpeditions.AsQueryable();


            query = query.Include(i => i.Items);

            if (!string.IsNullOrWhiteSpace(Keyword))
            {
                List <string> searchAttributes = new List <string>()
                {
                    "UnitPaymentOrderNo", "SupplierName", "DivisionName", "SupplierCode", "InvoiceNo"
                };

                query = QueryHelper <PurchasingDocumentExpedition> .ConfigureSearch(query, searchAttributes, Keyword);
            }

            if (Filter.Contains("verificationFilter"))
            {
                Filter = "{}";
                List <ExpeditionPosition> positions = new List <ExpeditionPosition> {
                    ExpeditionPosition.SEND_TO_PURCHASING_DIVISION, ExpeditionPosition.SEND_TO_ACCOUNTING_DIVISION, ExpeditionPosition.SEND_TO_CASHIER_DIVISION
                };
                query = query.Where(p => positions.Contains(p.Position));
            }

            Dictionary <string, string> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Filter);

            query = QueryHelper <PurchasingDocumentExpedition> .ConfigureFilter(query, FilterDictionary);

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Order);

            query = QueryHelper <PurchasingDocumentExpedition> .ConfigureOrder(query, OrderDictionary);

            Pageable <PurchasingDocumentExpedition> pageable = new Pageable <PurchasingDocumentExpedition>(query, Page - 1, Size);
            List <PurchasingDocumentExpedition>     Data     = pageable.Data.ToList();
            int TotalData = pageable.TotalCount;

            List <object> list = new List <object>();

            list.AddRange(Data.Select(s => new
            {
                UnitPaymentOrderId = s.Id,
                s.UnitPaymentOrderNo,
                s.UPODate,
                s.DueDate,
                s.InvoiceNo,
                s.SupplierCode,
                s.SupplierName,
                s.CategoryCode,
                s.CategoryName,
                s.DivisionCode,
                s.DivisionName,
                s.Vat,
                s.IncomeTax,
                s.IncomeTaxBy,
                s.IsPaid,
                s.TotalPaid,
                s.Currency,
                s.PaymentMethod,
                s.URNId,
                s.URNNo,
                Items = s.Items.Select(sl => new
                {
                    UnitPaymentOrderItemId = sl.Id,
                    sl.UnitId,
                    sl.UnitCode,
                    sl.UnitName,
                    sl.ProductId,
                    sl.ProductCode,
                    sl.ProductName,
                    sl.Quantity,
                    sl.Uom,
                    sl.Price,
                    sl.URNId,
                    sl.URNNo
                }).ToList()
            }));

            return(new ReadResponse <object>(list, TotalData, OrderDictionary));
        }
        public override Tuple <List <IncomeTax>, int, Dictionary <string, string>, List <string> > ReadModel(int Page = 1, int Size = 25, string Order = "{}", List <string> Select = null, string Keyword = null, string Filter = "{}")
        {
            IQueryable <IncomeTax>      Query            = this.DbContext.IncomeTaxes;
            Dictionary <string, object> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(Filter);

            Query = ConfigureFilter(Query, FilterDictionary);
            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Order);

            /* Search With Keyword */
            if (Keyword != null)
            {
                List <string> SearchAttributes = new List <string>()
                {
                    "Name"
                };

                Query = Query.Where(General.BuildSearch(SearchAttributes), Keyword);
            }

            /* Const Select */
            List <string> SelectedFields = new List <string>()
            {
                "Id", "name", "rate", "description"
            };

            Query = Query
                    .Select(v => new IncomeTax
            {
                Id            = v.Id,
                Name          = v.Name,
                Rate          = v.Rate,
                Description   = v.Description,
                COACodeCredit = v.COACodeCredit
            });

            /* Order */
            if (OrderDictionary.Count.Equals(0))
            {
                OrderDictionary.Add("_updatedDate", General.DESCENDING);

                Query = Query.OrderByDescending(b => b._LastModifiedUtc); /* Default Order */
            }
            else
            {
                string Key          = OrderDictionary.Keys.First();
                string OrderType    = OrderDictionary[Key];
                string TransformKey = General.TransformOrderBy(Key);

                BindingFlags IgnoreCase = BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance;

                Query = OrderType.Equals(General.ASCENDING) ?
                        Query.OrderBy(b => b.GetType().GetProperty(TransformKey, IgnoreCase).GetValue(b)) :
                        Query.OrderByDescending(b => b.GetType().GetProperty(TransformKey, IgnoreCase).GetValue(b));
            }

            /* Pagination */
            Pageable <IncomeTax> pageable = new Pageable <IncomeTax>(Query, Page - 1, Size);
            List <IncomeTax>     Data     = pageable.Data.ToList <IncomeTax>();

            int TotalData = pageable.TotalCount;

            return(Tuple.Create(Data, TotalData, OrderDictionary, SelectedFields));
        }
        public ReadResponse <object> GetReport(int Size, int Page, string DocumentNo, string UnitPaymentOrderNo, string InvoiceNo, string SupplierCode, string DivisionCode, string PaymentMethod, DateTimeOffset?DateFrom, DateTimeOffset?DateTo, int Offset)
        {
            IQueryable <BankExpenditureNoteReportViewModel> Query;

            if (DateFrom == null || DateTo == null)
            {
                Query = (from a in dbContext.BankExpenditureNotes
                         join b in dbContext.BankExpenditureNoteDetails on a.Id equals b.BankExpenditureNoteId
                         join c in dbContext.PurchasingDocumentExpeditions on b.UnitPaymentOrderId equals c.Id
                         where c.InvoiceNo == (InvoiceNo ?? c.InvoiceNo) &&
                         c.SupplierCode == (SupplierCode ?? c.SupplierCode) &&
                         c.UnitPaymentOrderNo == (UnitPaymentOrderNo ?? c.UnitPaymentOrderNo) &&
                         c.DivisionCode == (DivisionCode ?? c.DivisionCode) &&
                         !c.PaymentMethod.ToUpper().Equals("CASH") &&
                         c.IsPaid &&
                         c.PaymentMethod == (PaymentMethod ?? c.PaymentMethod)
                         where a.DocumentNo == (DocumentNo ?? a.DocumentNo)
                         orderby a.DocumentNo
                         select new BankExpenditureNoteReportViewModel
                {
                    DocumentNo = a.DocumentNo,
                    Currency = a.BankCurrencyCode,
                    Date = a.Date,
                    SupplierName = c.SupplierName,
                    CategoryName = c.CategoryName == null ? "-" : c.CategoryName,
                    DivisionName = c.DivisionName,
                    PaymentMethod = c.PaymentMethod,
                    UnitPaymentOrderNo = b.UnitPaymentOrderNo,
                    BankName = string.Concat(a.BankAccountName, " - ", a.BankName, " - ", a.BankAccountNumber, " - ", a.BankCurrencyCode),
                    DPP = c.TotalPaid - c.Vat,
                    VAT = c.Vat,
                    TotalPaid = c.TotalPaid,
                    InvoiceNumber = c.InvoiceNo
                }
                         );
            }
            else
            {
                Query = (from a in dbContext.BankExpenditureNotes
                         join b in dbContext.BankExpenditureNoteDetails on a.Id equals b.BankExpenditureNoteId
                         join c in dbContext.PurchasingDocumentExpeditions on b.UnitPaymentOrderId equals c.Id
                         where c.InvoiceNo == (InvoiceNo ?? c.InvoiceNo) &&
                         c.SupplierCode == (SupplierCode ?? c.SupplierCode) &&
                         c.UnitPaymentOrderNo == (UnitPaymentOrderNo ?? c.UnitPaymentOrderNo) &&
                         c.DivisionCode == (DivisionCode ?? c.DivisionCode) &&
                         !c.PaymentMethod.ToUpper().Equals("CASH") &&
                         c.IsPaid &&
                         c.PaymentMethod == (PaymentMethod ?? c.PaymentMethod)
                         where a.DocumentNo == (DocumentNo ?? a.DocumentNo) && a.Date.AddHours(Offset).Date >= DateFrom.Value.Date && a.Date.AddHours(Offset).Date <= DateTo.Value.Date
                         orderby a.DocumentNo
                         select new BankExpenditureNoteReportViewModel
                {
                    DocumentNo = a.DocumentNo,
                    Currency = a.BankCurrencyCode,
                    Date = a.Date,
                    SupplierName = c.SupplierName,
                    CategoryName = c.CategoryName == null ? "-" : c.CategoryName,
                    DivisionName = c.DivisionName,
                    PaymentMethod = c.PaymentMethod,
                    UnitPaymentOrderNo = b.UnitPaymentOrderNo,
                    BankName = string.Concat(a.BankAccountName, " - ", a.BankName, " - ", a.BankAccountNumber, " - ", a.BankCurrencyCode),
                    DPP = c.TotalPaid - c.Vat,
                    VAT = c.Vat,
                    TotalPaid = c.TotalPaid,
                    InvoiceNumber = c.InvoiceNo
                }
                         );
            }

            Pageable <BankExpenditureNoteReportViewModel> pageable = new Pageable <BankExpenditureNoteReportViewModel>(Query, Page - 1, Size);
            List <object> data = pageable.Data.ToList <object>();

            return(new ReadResponse <object>(data, pageable.TotalCount, new Dictionary <string, string>()));
        }
        public static Pageable <GridSortingViewModel> ToGridSortingViewModelList(this IEnumerable <SortModel> src, Pageable <GridSortingViewModel> dest)
        {
            if (src != null)
            {
                foreach (var s in src)
                {
                    dest.Add(ExampleMapper.MapToGridSortingViewModel(s));
                }
            }

            return(dest);
        }
        public ReadResponse <object> Read(int Page = 1, int Size = 25, string Order = "{}", string Keyword = null, string Filter = "{}")
        {
            IQueryable <BankExpenditureNoteModel> Query = this.dbSet;

            var queryItems = Query.Select(x => x.Details.Select(y => y.Items).ToList());

            Query = Query
                    .Select(s => new BankExpenditureNoteModel
            {
                Id                = s.Id,
                CreatedUtc        = s.CreatedUtc,
                LastModifiedUtc   = s.LastModifiedUtc,
                BankName          = s.BankName,
                BankAccountName   = s.BankAccountName,
                BankAccountNumber = s.BankAccountNumber,
                DocumentNo        = s.DocumentNo,
                SupplierName      = s.SupplierName,
                GrandTotal        = s.GrandTotal,
                BankCurrencyCode  = s.BankCurrencyCode,
                CurrencyRate      = s.CurrencyRate,
                IsPosted          = s.IsPosted,
                Details           = s.Details.Where(x => x.BankExpenditureNoteId == s.Id).Select(a => new BankExpenditureNoteDetailModel
                {
                    SupplierName       = a.SupplierName,
                    UnitPaymentOrderNo = a.UnitPaymentOrderNo,
                    Items = a.Items.Where(b => b.BankExpenditureNoteDetailId == a.Id).ToList()
                }).ToList()
            });

            List <string> searchAttributes = new List <string>()
            {
                "DocumentNo", "BankName", "SupplierName", "BankCurrencyCode"
            };

            Query = QueryHelper <BankExpenditureNoteModel> .ConfigureSearch(Query, searchAttributes, Keyword);

            Dictionary <string, string> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Filter);

            Query = QueryHelper <BankExpenditureNoteModel> .ConfigureFilter(Query, FilterDictionary);

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Order);

            Query = QueryHelper <BankExpenditureNoteModel> .ConfigureOrder(Query, OrderDictionary);

            Pageable <BankExpenditureNoteModel> pageable = new Pageable <BankExpenditureNoteModel>(Query, Page - 1, Size);
            List <BankExpenditureNoteModel>     Data     = pageable.Data.ToList();

            List <object> list = new List <object>();

            list.AddRange(
                Data.Select(s => new
            {
                s.Id,
                s.DocumentNo,
                s.CreatedUtc,
                s.BankName,
                s.BankAccountName,
                s.BankAccountNumber,
                s.SupplierName,
                s.GrandTotal,
                s.BankCurrencyCode,
                s.IsPosted,
                Details = s.Details.Select(sl => new { sl.SupplierName, sl.UnitPaymentOrderNo, sl.Items }).ToList(),
            }).ToList()
                );

            int TotalData = pageable.TotalCount;

            return(new ReadResponse <object>(list, TotalData, OrderDictionary));
        }
 public static Pageable <DummyViewModel> ToPageableDummyViewModel(IEnumerable <DummyModel> src, Pageable <DummyViewModel> dest)
 {
     if (src != null)
     {
         foreach (var s in src)
         {
             var dummyViewModel = new DummyViewModel();
             Map(s, dummyViewModel);
             dest.Add(dummyViewModel);
         }
     }
     return(dest);
 }
Beispiel #22
0
        public Tuple <List <object>, int, Dictionary <string, string> > Read(int page = 1, int size = 25, string order = "{}", string keyword = null, string filter = "{}")
        {
            IQueryable <PurchasingDocumentExpedition> Query = this.dbContext.PurchasingDocumentExpeditions;

            Query = Query
                    .Select(s => new PurchasingDocumentExpedition
            {
                Id = s.Id,
                UnitPaymentOrderNo = s.UnitPaymentOrderNo,
                UPODate            = s.UPODate,
                DueDate            = s.DueDate,
                InvoiceNo          = s.InvoiceNo,
                PaymentMethod      = s.PaymentMethod,
                SupplierCode       = s.SupplierCode,
                SupplierName       = s.SupplierName,
                CategoryCode       = s.CategoryCode,
                CategoryName       = s.CategoryName,
                DivisionCode       = s.DivisionCode,
                DivisionName       = s.DivisionName,
                TotalPaid          = s.TotalPaid,
                Currency           = s.Currency,
                Position           = s.Position,
                IsPaid             = s.IsPaid,
                IsPaidPPH          = s.IsPaidPPH,
                VerifyDate         = s.VerifyDate,
                LastModifiedUtc    = s.LastModifiedUtc,
                Active             = s.Active,
                IsDeleted          = s.IsDeleted,
                Vat       = s.Vat,
                IncomeTax = s.IncomeTax
            });

            List <string> searchAttributes = new List <string>()
            {
                "UnitPaymentOrderNo", "InvoiceNo", "SupplierName", "DivisionName"
            };

            Query = QueryHelper <PurchasingDocumentExpedition> .ConfigureSearch(Query, searchAttributes, keyword);

            if (filter.Contains("verificationFilter"))
            {
                filter = "{}";
                List <ExpeditionPosition> positions = new List <ExpeditionPosition> {
                    ExpeditionPosition.SEND_TO_PURCHASING_DIVISION, ExpeditionPosition.SEND_TO_ACCOUNTING_DIVISION, ExpeditionPosition.SEND_TO_CASHIER_DIVISION
                };
                Query = Query.Where(p => positions.Contains(p.Position));
            }

            Dictionary <string, string> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(filter);

            Query = QueryHelper <PurchasingDocumentExpedition> .ConfigureFilter(Query, FilterDictionary);

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(order);

            Query = QueryHelper <PurchasingDocumentExpedition> .ConfigureOrder(Query, OrderDictionary);

            Pageable <PurchasingDocumentExpedition> pageable = new Pageable <PurchasingDocumentExpedition>(Query, page - 1, size);
            List <PurchasingDocumentExpedition>     Data     = pageable.Data.ToList <PurchasingDocumentExpedition>();
            int TotalData = pageable.TotalCount;

            List <object> list = new List <object>();

            list.AddRange(
                Data.Select(s => new
            {
                Id = s.Id,
                UnitPaymentOrderNo = s.UnitPaymentOrderNo,
                UPODate            = s.UPODate,
                InvoiceNo          = s.InvoiceNo,
                PaymentMethod      = s.PaymentMethod,
                DueDate            = s.DueDate,
                SupplierName       = s.SupplierName,
                CategoryName       = s.CategoryName,
                DivisionName       = s.DivisionName,
                TotalPaid          = s.TotalPaid,
                Currency           = s.Currency,
                Position           = s.Position,
                VerifyDate         = s.VerifyDate,
                _LastModifiedUtc   = s.LastModifiedUtc,
                s.Active,
                s.IsDeleted,
                s.IncomeTax,
                s.Vat
            }).ToList()
                );

            return(Tuple.Create(list, TotalData, OrderDictionary));
        }
Beispiel #23
0
        public void QueryEntities()
        {
            string storageUri        = StorageUri;
            string accountName       = StorageAccountName;
            string storageAccountKey = PrimaryStorageAccountKey;
            string tableName         = "OfficeSupplies4p1";
            string partitionKey      = "somePartition";
            string rowKey            = "1";
            string rowKey2           = "2";

            var serviceClient = new TableServiceClient(
                new Uri(storageUri),
                new TableSharedKeyCredential(accountName, storageAccountKey));

            serviceClient.CreateTable(tableName);
            var tableClient = serviceClient.GetTableClient(tableName);

            var entity = new TableEntity(partitionKey, rowKey)
            {
                { "Product", "Markers" },
                { "Price", 5.00 },
                { "Quantity", 34 }
            };

            tableClient.AddEntity(entity);

            var entity2 = new TableEntity(partitionKey, rowKey2)
            {
                { "Product", "Planner" },
                { "Price", 7.00 },
                { "Quantity", 34 }
            };

            tableClient.AddEntity(entity2);

            #region Snippet:TablesSample4QueryEntitiesFilter
            Pageable <TableEntity> queryResultsFilter = tableClient.Query <TableEntity>(filter: $"PartitionKey eq '{partitionKey}'");

            // Iterate the <see cref="Pageable"> to access all queried entities.
            foreach (TableEntity qEntity in queryResultsFilter)
            {
                Console.WriteLine($"{qEntity.GetString("Product")}: {qEntity.GetDouble("Price")}");
            }

            Console.WriteLine($"The query returned {queryResultsFilter.Count()} entities.");
            #endregion

            #region Snippet:TablesSample4QueryEntitiesFilterWithQueryFilter
            // The CreateQueryFilter method is also available to assist with properly formatting and escaping OData queries.
#if SNIPPET
            Pageable <TableEntity> queryResultsFilter = tableClient.Query <TableEntity>(filter: TableClient.CreateQueryFilter($"PartitionKey eq {partitionKey}"));
#else
            queryResultsFilter = tableClient.Query <TableEntity>(filter: TableClient.CreateQueryFilter($"PartitionKey eq {partitionKey}"));
#endif
            // Iterate the <see cref="Pageable"> to access all queried entities.
            foreach (TableEntity qEntity in queryResultsFilter)
            {
                Console.WriteLine($"{qEntity.GetString("Product")}: {qEntity.GetDouble("Price")}");
            }

            Console.WriteLine($"The query returned {queryResultsFilter.Count()} entities.");

            #endregion
            #region Snippet:TablesSample4QueryEntitiesExpression
            double priceCutOff = 6.00;
            Pageable <OfficeSupplyEntity> queryResultsLINQ = tableClient.Query <OfficeSupplyEntity>(ent => ent.Price >= priceCutOff);
            #endregion

            #region Snippet:TablesMigrationQuery
            // Execute the query.
            Pageable <OfficeSupplyEntity> queryResults = tableClient.Query <OfficeSupplyEntity>(e => e.PartitionKey == partitionKey && e.RowKey == rowKey);

            // Display the results
            foreach (var item in queryResults.ToList())
            {
                Console.WriteLine($"{item.PartitionKey}, {item.RowKey}, {item.Product}, {item.Price}, {item.Quantity}");
            }
            #endregion

            #region Snippet:TablesSample4QueryEntitiesSelect
            Pageable <TableEntity> queryResultsSelect = tableClient.Query <TableEntity>(select: new List <string>()
            {
                "Product", "Price"
            });
            #endregion

            #region Snippet:TablesSample4QueryEntitiesMaxPerPage
            Pageable <TableEntity> queryResultsMaxPerPage = tableClient.Query <TableEntity>(maxPerPage: 10);

            // Iterate the <see cref="Pageable"> by page.

            foreach (Page <TableEntity> page in queryResultsMaxPerPage.AsPages())
            {
                Console.WriteLine("This is a new page!");
                foreach (TableEntity qEntity in page.Values)
                {
                    Console.WriteLine($"# of {qEntity.GetString("Product")} inventoried: {qEntity.GetInt32("Quantity")}");
                }
            }
            #endregion

            serviceClient.DeleteTable(tableName);
        }
Beispiel #24
0
        public ReadResponse <ClearaceVBViewModel> Read(int page, int size, string order, List <string> select, string keyword, string filter)
        {
            var query            = _RequestDbSet.AsQueryable();
            var realizationQuery = _RealizationDbSet.AsQueryable().Where(s => s.Position == VBRealizationPosition.Cashier);

            List <string> SearchAttributes = new List <string>()
            {
                "RqstNo", "Appliciant", "RealNo", "Status", "DiffStatus"
            };

            var vbRequestQuery     = _RequestDbSet.AsQueryable();
            var vbRealizationQuery = _RealizationDbSet.AsQueryable().Where(s => s.Position == VBRealizationPosition.Cashier);

            var newQuery = from realization in vbRealizationQuery
                           join request in vbRequestQuery on realization.VBRequestDocumentId equals request.Id into vbRequestRealizations

                           from vbRequestRealization in vbRequestRealizations.DefaultIfEmpty()
                           select new ClearaceVBViewModel()
            {
                Id = realization.VBRequestDocumentId,
                VBRealizationDocumentId = realization.Id,
                RqstNo     = realization.VBRequestDocumentNo,
                VBCategory = realization.Type,
                RqstDate   = realization.VBRequestDocumentDate,
                //RqstDate = rqst.Date.AddHours(7).ToString("dd MMMM yyyy", new CultureInfo("id-ID")),
                Unit = new Unit()
                {
                    Id   = realization.SuppliantUnitId,
                    Name = realization.SuppliantUnitName,
                },
                Appliciant = realization.VBRequestDocumentCreatedBy,
                RealNo     = realization.DocumentNo,
                RealDate   = realization.Date,
                //RealDate = rqst.Realization_Status == true ? real.Date.AddHours(7).ToString("dd MMMM yyyy", new CultureInfo("id-ID")) : "",
                VerDate = realization.VerificationDate,
                //VerDate = real.isVerified == true ? real.VerifiedDate.AddHours(7).ToString("dd MMMM yyyy", new CultureInfo("id-ID")) : "",
                //DiffStatus = real.StatusReqReal,
                DiffAmount    = realization.VBRequestDocumentAmount - realization.Amount,
                ClearanceDate = vbRequestRealization != null ? vbRequestRealization.CompletedDate : realization.CompletedDate,
                DiffStatus    = realization.VBRequestDocumentAmount - realization.Amount < 0 ? "Kurang" : realization.VBRequestDocumentAmount - realization.Amount > 0 ? "Sisa" : "Sesuai",
                //ClearanceDate = rqst.Complete_Status == true ? rqst.CompleteDate.ToString() : "",
                IsPosted        = vbRequestRealization != null ? vbRequestRealization.IsCompleted : realization.IsCompleted,
                Status          = vbRequestRealization != null ? vbRequestRealization.IsCompleted ? "Completed" : "Uncompleted" : "",
                LastModifiedUtc = realization.LastModifiedUtc,
                CurrencyCode    = realization.CurrencyCode
            };

            //var data = query
            //   .Join(realizationQuery,
            //   (rqst) => rqst.Id,
            //   (real) => real.VBRequestDocumentId,
            //   (rqst, real) => new ClearaceVBViewModel()
            //   {
            //       Id = rqst.Id,
            //       VBRealizationDocumentId = real.Id,
            //       RqstNo = rqst.DocumentNo,
            //       VBCategory = rqst.Type,
            //       RqstDate = rqst.Date,
            //       //RqstDate = rqst.Date.AddHours(7).ToString("dd MMMM yyyy", new CultureInfo("id-ID")),
            //       Unit = new Unit()
            //       {
            //           Id = rqst.SuppliantUnitId,
            //           Name = rqst.SuppliantUnitName,
            //       },
            //       Appliciant = rqst.CreatedBy,
            //       RealNo = real.DocumentNo,
            //       RealDate = real.Date,
            //       //RealDate = rqst.Realization_Status == true ? real.Date.AddHours(7).ToString("dd MMMM yyyy", new CultureInfo("id-ID")) : "",
            //       VerDate = real.VerificationDate,
            //       //VerDate = real.isVerified == true ? real.VerifiedDate.AddHours(7).ToString("dd MMMM yyyy", new CultureInfo("id-ID")) : "",
            //       //DiffStatus = real.StatusReqReal,
            //       DiffAmount = rqst.Amount - real.Amount,
            //       ClearanceDate = rqst.CompletedDate,
            //       DiffStatus = rqst.Amount - real.Amount < 0 ? "Kurang" : rqst.Amount - real.Amount > 0 ? "Sisa" : "Sesuai",
            //       //ClearanceDate = rqst.Complete_Status == true ? rqst.CompleteDate.ToString() : "",
            //       IsPosted = rqst.IsCompleted,
            //       Status = rqst.IsCompleted ? "Completed" : "Uncompleted",
            //       LastModifiedUtc = real.LastModifiedUtc,
            //   })
            //   .OrderByDescending(s => s.LastModifiedUtc).AsQueryable();

            newQuery = newQuery.OrderByDescending(entity => entity.LastModifiedUtc);
            newQuery = Search(newQuery, SearchAttributes, keyword);

            var filterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(filter);

            newQuery = Filter(newQuery, filterDictionary);

            var orderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(order);

            newQuery = Order(newQuery, orderDictionary);

            var pageable = new Pageable <ClearaceVBViewModel>(newQuery, page - 1, size);
            var data     = pageable.Data.ToList();

            int totalData = pageable.TotalCount;

            return(new ReadResponse <ClearaceVBViewModel>(data, totalData, orderDictionary, new List <string>()));
        }
Beispiel #25
0
 /// <summary>
 ///
 /// </summary>
 public Resources([JsonProperty("list")] IEnumerable <T> resourcesList,
                  [JsonProperty("totalCount")] long total,
                  [JsonProperty("Pageable")] Pageable pageable)
     : this(resourcesList, total, pageable.PageNo, pageable.PageSize)
 {
 }
Beispiel #26
0
        public void ThreadCGUD_ParticipantAUR_MessageGSU_NotificationT()
        {
            //arr
            Console.WriteLine($"ThreadCGUD_ParticipantAUR_MessageGSU_NotificationT Running on RecordedTestMode : {Mode}");
            CommunicationIdentityClient communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient();

            (CommunicationUserIdentifier user1, string token1) = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUserIdentifier user2, _)             = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUserIdentifier user3, string token3) = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUserIdentifier user4, _)             = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUserIdentifier user5, _)             = CreateUserAndToken(communicationIdentityClient);

            string repeatabilityRequestId1 = "contoso-F0A747F1-6245-4307-8267-B974340677D2";
            string repeatabilityRequestId2 = "contoso-A0A747F1-6245-4307-8267-B974340677DA";

            var topic = "Thread sync from C# sdk";
            var displayNameMessage = "DisplayName sender message 1";
            var participants       = new[]
            {
                new ChatParticipant(user1),
                new ChatParticipant(user2),
                new ChatParticipant(user3)
            };
            ChatClient chatClient  = CreateInstrumentedChatClient(token1);
            ChatClient chatClient3 = CreateInstrumentedChatClient(token3);

            //act
            CreateChatThreadResult createChatThreadResult = chatClient.CreateChatThread(topic, participants, repeatabilityRequestId1);
            ChatThreadClient       chatThreadClient       = GetInstrumentedChatThreadClient(chatClient, createChatThreadResult.ChatThread.Id);
            var threadId = chatThreadClient.Id;

            CreateChatThreadResult createChatThreadResult2 = chatClient.CreateChatThread(topic, participants, repeatabilityRequestId2);
            ChatThreadClient       chatThreadClient2       = GetInstrumentedChatThreadClient(chatClient, createChatThreadResult2.ChatThread.Id);
            ChatThreadClient       chatThreadClient3       = GetInstrumentedChatThreadClient(chatClient3, threadId);

            Pageable <ChatParticipant> chatParticipantsOnCreation = chatThreadClient.GetParticipants();
            var chatParticipantsOnCreationCount = chatParticipantsOnCreation.Count();

            string updatedTopic = "Launch meeting";

            chatThreadClient.UpdateTopic(topic: "Launch meeting");

            ChatThread chatThread = chatClient.GetChatThread(threadId);

            string messageContent  = "Let's meet at 11am";
            string messageId       = chatThreadClient.SendMessage("Let's meet at 11am");
            string messageContent2 = "Content for message 2";
            string messageId2      = chatThreadClient2.SendMessage(messageContent2, ChatMessageType.Text, displayNameMessage);
            string messageContent3 = "Content for message 3";
            string messageId3      = chatThreadClient3.SendMessage(messageContent3, ChatMessageType.Html, displayNameMessage);
            string messageContent4 = "Content for message 4";
            string messageId4      = chatThreadClient3.SendMessage(messageContent4, ChatMessageType.Text, displayNameMessage);
            string messageContent5 = "Content for message 5";
            string messageId5      = chatThreadClient3.SendMessage(messageContent5, ChatMessageType.Html, displayNameMessage);
            string messageContent6 = "Content for message 6";
            string messageId6      = chatThreadClient3.SendMessage(messageContent6, ChatMessageType.Text, displayNameMessage);

            ChatMessage message  = chatThreadClient.GetMessage(messageId);
            ChatMessage message2 = chatThreadClient2.GetMessage(messageId2);
            ChatMessage message3 = chatThreadClient3.GetMessage(messageId3);
            ChatMessage message4 = chatThreadClient3.GetMessage(messageId4);
            ChatMessage message5 = chatThreadClient3.GetMessage(messageId5);
            ChatMessage message6 = chatThreadClient3.GetMessage(messageId6);

            Pageable <ChatMessage> messages  = chatThreadClient.GetMessages();
            Pageable <ChatMessage> messages2 = chatThreadClient2.GetMessages();
            var getMessagesCount             = messages.Count();
            var getMessagesCount2            = messages2.Count();

            Pageable <ChatMessage> pageableMessages = chatThreadClient.GetMessages();

            PageableTester <ChatMessage> .AssertPagination(enumerableResource : pageableMessages, expectedPageSize : 2, expectedTotalResources : 8);

            string updatedMessageContent = "Instead of 11am, let's meet at 2pm";

            chatThreadClient.UpdateMessage(messageId, content: "Instead of 11am, let's meet at 2pm");
            Response <ChatMessage> actualUpdateMessage = chatThreadClient.GetMessage(messageId);

            chatThreadClient.DeleteMessage(messageId);
            Pageable <ChatMessage> messagesAfterOneDeleted = chatThreadClient.GetMessages();
            ChatMessage            deletedChatMessage      = messagesAfterOneDeleted.First(x => x.Id == messageId);

            Pageable <ChatParticipant> chatParticipants = chatThreadClient.GetParticipants();
            var chatParticipantsCount = chatParticipants.Count();

            var newParticipant  = new ChatParticipant(user4);
            var newParticipant2 = new ChatParticipant(user5);

            chatThreadClient.AddParticipants(participants: new[] { newParticipant });
            AddChatParticipantsResult addChatParticipantsResult = chatThreadClient.AddParticipant(newParticipant2);

            Pageable <ChatParticipant> chatParticipantsAfterTwoAdded = chatThreadClient.GetParticipants();

            PageableTester <ChatParticipant> .AssertPagination(enumerableResource : chatParticipantsAfterTwoAdded, expectedPageSize : 2, expectedTotalResources : 5);

            var chatParticipantsAfterTwoAddedCount = chatParticipantsAfterTwoAdded.Count();

            CommunicationUserIdentifier participantToBeRemoved = user4;

            chatThreadClient.RemoveParticipant(user: participantToBeRemoved);
            Pageable <ChatParticipant> chatParticipantAfterOneDeleted = chatThreadClient.GetParticipants();
            var chatParticipantAfterOneDeletedCount = chatParticipantAfterOneDeleted.Count();

            Response typingNotificationResponse = chatThreadClient.SendTypingNotification();

            chatThreadClient.SendTypingNotification();

            Pageable <ChatThreadInfo> threads = chatClient.GetChatThreadsInfo();
            var threadsCount = threads.Count();

            chatClient.DeleteChatThread(threadId);

            //assert
            Assert.AreEqual(updatedTopic, chatThread.Topic);
            Assert.AreEqual(3, chatParticipantsOnCreationCount);
            Assert.AreEqual(messageContent, message.Content.Message);
            Assert.AreEqual(updatedMessageContent, actualUpdateMessage.Value.Content.Message);
            Assert.AreEqual(ChatMessageType.Text, message.Type);

            Assert.AreEqual(messageContent2, message2.Content.Message);
            Assert.AreEqual(displayNameMessage, message2.SenderDisplayName);
            Assert.AreEqual(messageContent3, message3.Content.Message);
            Assert.AreEqual(messageContent4, message4.Content.Message);
            Assert.AreEqual(messageContent5, message5.Content.Message);
            Assert.AreEqual(messageContent6, message6.Content.Message);

            Assert.AreEqual(2, threadsCount);
            Assert.AreEqual(8, getMessagesCount);  //Including all types : 5 text message, 3 control messages
            Assert.AreEqual(3, getMessagesCount2); //Including all types : 1 text message, 2 control messages

            Assert.IsTrue(deletedChatMessage.DeletedOn.HasValue);
            Assert.AreEqual(3, chatParticipantsCount);
            Assert.AreEqual(5, chatParticipantsAfterTwoAddedCount);
            Assert.AreEqual(4, chatParticipantAfterOneDeletedCount);
            Assert.IsNull(addChatParticipantsResult.Errors);
            Assert.AreEqual((int)HttpStatusCode.OK, typingNotificationResponse.Status);
        }
        public override Tuple <List <Category>, int, Dictionary <string, string>, List <string> > ReadModel(int Page = 1, int Size = 25, string Order = "{}", List <string> Select = null, string Keyword = null, string Filter = "{}")
        {
            IQueryable <Category>       Query            = this.DbContext.Categories;
            Dictionary <string, object> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(Filter);

            Query = ConfigureFilter(Query, FilterDictionary);
            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Order);

            /* Search With Keyword */
            if (Keyword != null)
            {
                List <string> SearchAttributes = new List <string>()
                {
                    "Code", "Name"
                };

                Query = Query.Where(General.BuildSearch(SearchAttributes), Keyword);
            }

            /* Const Select */
            List <string> SelectedFields = new List <string>()
            {
                "_id", "code", "name", "PurchasingCOA", "StockCOA", "LocalDebtCOA", "ImportDebtCOA"
            };

            Query = Query
                    .Select(b => new Category
            {
                Id            = b.Id,
                Code          = b.Code,
                Name          = b.Name,
                PurchasingCOA = b.PurchasingCOA,
                StockCOA      = b.StockCOA,
                LocalDebtCOA  = b.LocalDebtCOA,
                ImportDebtCOA = b.ImportDebtCOA
            });

            /* Order */
            if (OrderDictionary.Count.Equals(0))
            {
                OrderDictionary.Add("_updatedDate", General.DESCENDING);

                Query = Query.OrderByDescending(b => b._LastModifiedUtc); /* Default Order */
            }
            else
            {
                string Key          = OrderDictionary.Keys.First();
                string OrderType    = OrderDictionary[Key];
                string TransformKey = General.TransformOrderBy(Key);

                BindingFlags IgnoreCase = BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance;

                Query = OrderType.Equals(General.ASCENDING) ?
                        Query.OrderBy(b => b.GetType().GetProperty(TransformKey, IgnoreCase).GetValue(b)) :
                        Query.OrderByDescending(b => b.GetType().GetProperty(TransformKey, IgnoreCase).GetValue(b));
            }

            /* Pagination */
            Pageable <Category> pageable = new Pageable <Category>(Query, Page - 1, Size);
            List <Category>     Data     = pageable.Data.ToList <Category>();

            int TotalData = pageable.TotalCount;

            return(Tuple.Create(Data, TotalData, OrderDictionary, SelectedFields));
        }
Beispiel #28
0
        public ReadResponse <DailyBankTransactionModel> Read(int page, int size, string order, List <string> select, string keyword, string filter)
        {
            IQueryable <DailyBankTransactionModel> Query = _DbSet;

            Query = Query
                    .Select(s => new DailyBankTransactionModel
            {
                Id                        = s.Id,
                CreatedUtc                = s.CreatedUtc,
                Code                      = s.Code,
                LastModifiedUtc           = s.LastModifiedUtc,
                AccountBankName           = s.AccountBankName,
                AccountBankAccountName    = s.AccountBankAccountName,
                AccountBankAccountNumber  = s.AccountBankAccountNumber,
                AccountBankCode           = s.AccountBankCode,
                AccountBankCurrencyCode   = s.AccountBankCurrencyCode,
                AccountBankCurrencyId     = s.AccountBankCurrencyId,
                AccountBankCurrencySymbol = s.AccountBankCurrencySymbol,
                AccountBankId             = s.AccountBankId,
                Date                      = s.Date,
                ReferenceNo               = s.ReferenceNo,
                ReferenceType             = s.ReferenceType,
                Status                    = s.Status,
                SourceType                = s.SourceType
            });

            List <string> searchAttributes = new List <string>()
            {
                "Code", "ReferenceNo", "ReferenceType", "AccountBankName", "AccountBankCurrencyCode", "Status", "SourceType"
            };

            Query = QueryHelper <DailyBankTransactionModel> .Search(Query, searchAttributes, keyword);

            Dictionary <string, object> FilterDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(filter);

            Query = QueryHelper <DailyBankTransactionModel> .Filter(Query, FilterDictionary);

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(order);

            Query = QueryHelper <DailyBankTransactionModel> .Order(Query, OrderDictionary);

            Pageable <DailyBankTransactionModel> pageable = new Pageable <DailyBankTransactionModel>(Query, page - 1, size);
            List <DailyBankTransactionModel>     Data     = pageable.Data.ToList();

            List <DailyBankTransactionModel> list = new List <DailyBankTransactionModel>();

            list.AddRange(
                Data.Select(s => new DailyBankTransactionModel
            {
                Id                        = s.Id,
                CreatedUtc                = s.CreatedUtc,
                Code                      = s.Code,
                LastModifiedUtc           = s.LastModifiedUtc,
                AccountBankName           = s.AccountBankName,
                AccountBankAccountName    = s.AccountBankAccountName,
                AccountBankAccountNumber  = s.AccountBankAccountNumber,
                AccountBankCode           = s.AccountBankCode,
                AccountBankCurrencyCode   = s.AccountBankCurrencyCode,
                AccountBankCurrencyId     = s.AccountBankCurrencyId,
                AccountBankCurrencySymbol = s.AccountBankCurrencySymbol,
                AccountBankId             = s.AccountBankId,
                Date                      = s.Date,
                ReferenceNo               = s.ReferenceNo,
                ReferenceType             = s.ReferenceType,
                Status                    = s.Status,
                SourceType                = s.SourceType
            }).ToList()
                );

            int TotalData = pageable.TotalCount;

            return(new ReadResponse <DailyBankTransactionModel>(list, TotalData, OrderDictionary, new List <string>()));
        }
Beispiel #29
0
        public void ThreadCGUD_MemberAUR_MessageGSU_NotificationT()
        {
            //arr
            Console.WriteLine($"ThreadCGUD_MemberAUR_MessageGSU_NotificationT Running on RecordedTestMode : {Mode}");
            CommunicationIdentityClient communicationIdentityClient = CreateInstrumentedCommunicationIdentityClient();

            (CommunicationUserIdentifier user1, string token1) = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUserIdentifier user2, string token2) = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUserIdentifier user3, string token3) = CreateUserAndToken(communicationIdentityClient);
            (CommunicationUserIdentifier user4, string token4) = CreateUserAndToken(communicationIdentityClient);

            var topic = "Thread sync from C# sdk";
            var displayNameMessage = "DisplayName sender message 1";
            var members            = new List <ChatThreadMember>
            {
                new ChatThreadMember(user1),
                new ChatThreadMember(user2),
                new ChatThreadMember(user3)
            };
            ChatClient chatClient  = CreateInstrumentedChatClient(token1);
            ChatClient chatClient2 = CreateInstrumentedChatClient(token2);
            ChatClient chatClient3 = CreateInstrumentedChatClient(token3);

            //act
            #region Snippet:Azure_Communication_Chat_Tests_E2E_InitializeChatThreadClient
            //@@ChatThreadClient chatThreadClient1 = chatClient.CreateChatThread("Thread topic", members);
            // Alternatively, if you have created a chat thread before and you have its threadId, you can create a ChatThreadClient instance using:
            //@@ChatThreadClient chatThreadClient2 = chatClient.GetChatThreadClient("threadId");
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_InitializeChatThreadClient
            ChatThreadClient chatThreadClient = CreateInstrumentedChatThreadClient(chatClient, topic, members);
            var threadId = chatThreadClient.Id;
            ChatThreadClient chatThreadClient2 = CreateInstrumentedChatThreadClient(chatClient, topic, members);
            ChatThreadClient chatThreadClient3 = GetInstrumentedChatThreadClient(chatClient3, threadId);

            string updatedTopic = "Launch meeting";
            #region Snippet:Azure_Communication_Chat_Tests_E2E_UpdateThread
            chatThreadClient.UpdateThread(topic: "Launch meeting");
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_UpdateThread

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetChatThread
            ChatThread chatThread = chatClient.GetChatThread(threadId);
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetChatThread

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetChatThreadsInfo
            Pageable <ChatThreadInfo> threads = chatClient.GetChatThreadsInfo();
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetChatThreadsInfo
            var threadsCount = threads.Count();

            string messageContent = "Let's meet at 11am";
            #region Snippet:Azure_Communication_Chat_Tests_E2E_SendMessage
            SendChatMessageResult sendChatMessageResult = chatThreadClient.SendMessage("Let's meet at 11am");
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_SendMessage
            var messageContent2 = "Content for message 2";
            SendChatMessageResult sendChatMessageResult2 = chatThreadClient2.SendMessage(messageContent2, ChatMessagePriority.High, displayNameMessage);
            var messageContent3 = "Content for message 3";
            SendChatMessageResult sendChatMessageResult3 = chatThreadClient3.SendMessage(messageContent3, ChatMessagePriority.High, displayNameMessage);
            var messageContent4 = "Content for message 4";
            SendChatMessageResult sendChatMessageResult4 = chatThreadClient3.SendMessage(messageContent4, ChatMessagePriority.High, displayNameMessage);
            var messageContent5 = "Content for message 5";
            SendChatMessageResult sendChatMessageResult5 = chatThreadClient3.SendMessage(messageContent5, ChatMessagePriority.High, displayNameMessage);
            var messageContent6 = "Content for message 6";
            SendChatMessageResult sendChatMessageResult6 = chatThreadClient3.SendMessage(messageContent6, ChatMessagePriority.High, displayNameMessage);

            var messageId  = sendChatMessageResult.Id;
            var messageId2 = sendChatMessageResult2.Id;
            var messageId3 = sendChatMessageResult3.Id;
            var messageId4 = sendChatMessageResult4.Id;
            var messageId5 = sendChatMessageResult5.Id;
            var messageId6 = sendChatMessageResult6.Id;

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetMessage
            ChatMessage message = chatThreadClient.GetMessage(messageId);
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetMessage
            ChatMessage message2 = chatThreadClient2.GetMessage(messageId2);
            ChatMessage message3 = chatThreadClient3.GetMessage(messageId3);
            ChatMessage message4 = chatThreadClient3.GetMessage(messageId4);
            ChatMessage message5 = chatThreadClient3.GetMessage(messageId5);
            ChatMessage message6 = chatThreadClient3.GetMessage(messageId6);

            #region Snippet:Azure_Communication_Chat_Tests_E2E_GetMessages
            Pageable <ChatMessage> messages = chatThreadClient.GetMessages();
            #endregion Snippet:Azure_Communication_Chat_Tests_E2E_GetMessages
            Pageable <ChatMessage> messages2 = chatThreadClient2.GetMessages();
            var getMessagesCount             = messages.Count();
            var getMessagesCount2            = messages2.Count();

            # region Pagination assertions
Beispiel #30
0
        public async Task <ReadResponse <object> > GetReport(int Size, int Page, string Order, string UnitPaymentOrderNo, string SupplierCode, DateTimeOffset?DateFrom, DateTimeOffset?DateTo, int Offset)
        {
            if (!DateFrom.HasValue && !DateTo.HasValue)
            {
                DateFrom = DateTimeOffset.Now.AddHours(Offset).AddMonths(-1);
                DateTo   = DateTimeOffset.Now.AddHours(Offset);
            }
            else if (!DateFrom.HasValue && DateTo.HasValue)
            {
                DateTo   = DateTo.Value.AddHours(Offset);
                DateFrom = DateTo.Value.AddMonths(-1);
            }
            else if (DateFrom.HasValue && !DateTo.HasValue)
            {
                DateFrom = DateFrom.Value.AddHours(Offset);
                DateTo   = DateFrom.Value.AddMonths(1);
            }
            else
            {
                DateFrom = DateFrom.Value.AddHours(Offset);
                DateTo   = DateTo.Value.AddHours(Offset);
            }
            var listData = GetPurchasingDocumentExpedition(Size, Page, UnitPaymentOrderNo, SupplierCode, DateFrom.Value, DateTo.Value);

            List <UnitPaymentOrderUnpaidViewModel> dataMongo = await GetReportMongo(UnitPaymentOrderNo, SupplierCode, DateFrom.Value, DateTo.Value);

            IQueryable <UnitPaymentOrderUnpaidViewModel> resultQuery =
                (from a in dataMongo
                 join b in listData on a.UnitPaymentOrderNo equals b.UnitPaymentOrderNo into ab
                 from b in ab.DefaultIfEmpty()
                 select new UnitPaymentOrderUnpaidViewModel
            {
                UnitPaymentOrderNo = a.UnitPaymentOrderNo,
                UPODate = a.UPODate,
                InvoiceNo = a.InvoiceNo,
                SupplierName = a.SupplierName,
                Currency = a.Currency,
                IncomeTax = b == null ? 0 : b.IncomeTax,
                DPPVat = b == null ? 0 : b.DPPVat,
                DueDate = a.DueDate,
                ProductName = a.ProductName,
                Quantity = a.Quantity,
                UnitName = a.UnitName,
                TotalPaid = 0
            }).AsQueryable();

            Dictionary <string, string> OrderDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(Order);

            if (OrderDictionary.Count > 0)
            {
                string Key        = OrderDictionary.Keys.First();
                string OrderType  = OrderDictionary[Key];
                string orderField = string.Concat(Key.Replace(".", ""), " ", OrderType);
                resultQuery = resultQuery.OrderBy(orderField);
            }

            Pageable <UnitPaymentOrderUnpaidViewModel> pageable = new Pageable <UnitPaymentOrderUnpaidViewModel>(resultQuery, Page - 1, Size);
            List <UnitPaymentOrderUnpaidViewModel>     Data     = await pageable.Data.ToDynamicListAsync <UnitPaymentOrderUnpaidViewModel>();

            int TotalData = pageable.TotalCount;

            return(new ReadResponse <object>(Data.ToList <object>(), TotalData, OrderDictionary));
        }