public async Task <int> Count(OrderStatusFilter filter) { IQueryable <OrderStatusDAO> OrderStatusDAOs = DataContext.OrderStatus; OrderStatusDAOs = DynamicFilter(OrderStatusDAOs, filter); return(await OrderStatusDAOs.CountAsync()); }
public async Task <List <OrderDetail_OrderStatusDTO> > SingleListOrderStatus([FromBody] OrderDetail_OrderStatusFilterDTO OrderDetail_OrderStatusFilterDTO) { OrderStatusFilter OrderStatusFilter = new OrderStatusFilter(); OrderStatusFilter.Skip = 0; OrderStatusFilter.Take = 20; OrderStatusFilter.OrderBy = OrderStatusOrder.Id; OrderStatusFilter.OrderType = OrderType.ASC; OrderStatusFilter.Selects = OrderStatusSelect.ALL; OrderStatusFilter.Id = new LongFilter { Equal = OrderDetail_OrderStatusFilterDTO.Id }; OrderStatusFilter.Code = new StringFilter { StartsWith = OrderDetail_OrderStatusFilterDTO.Code }; OrderStatusFilter.Name = new StringFilter { StartsWith = OrderDetail_OrderStatusFilterDTO.Name }; OrderStatusFilter.Description = new StringFilter { StartsWith = OrderDetail_OrderStatusFilterDTO.Description }; List <OrderStatus> OrderStatuss = await OrderStatusService.List(OrderStatusFilter); List <OrderDetail_OrderStatusDTO> OrderDetail_OrderStatusDTOs = OrderStatuss .Select(x => new OrderDetail_OrderStatusDTO(x)).ToList(); return(OrderDetail_OrderStatusDTOs); }
public List <OrderStatusFilter> GetOrderStatusFilter(int tenantId, int userId, int pageID) { DataSet ds = new DataSet(); List <OrderStatusFilter> orderStatusFilter = new List <OrderStatusFilter>(); try { conn.Open(); MySqlCommand cmd = new MySqlCommand("SP_PHYGetOrdersStatusFilter", conn) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@_TenantID", tenantId); cmd.Parameters.AddWithValue("@_UserID", userId); cmd.Parameters.AddWithValue("@_PageID", pageID); MySqlDataAdapter da = new MySqlDataAdapter { SelectCommand = cmd }; da.Fill(ds); if (ds != null && ds.Tables[0] != null) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { OrderStatusFilter obj = new OrderStatusFilter { StatusID = Convert.ToInt32(ds.Tables[0].Rows[i]["StatusID"]), StatusName = Convert.ToString(ds.Tables[0].Rows[i]["StatusName"]) }; orderStatusFilter.Add(obj); } } } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } if (ds != null) { ds.Dispose(); } } return(orderStatusFilter); }
public async Task <int> Count([FromBody] OrderStatusMaster_OrderStatusFilterDTO OrderStatusMaster_OrderStatusFilterDTO) { if (!ModelState.IsValid) { throw new MessageException(ModelState); } OrderStatusFilter OrderStatusFilter = ConvertFilterDTOToFilterEntity(OrderStatusMaster_OrderStatusFilterDTO); return(await OrderStatusService.Count(OrderStatusFilter)); }
public async Task <List <OrderStatusMaster_OrderStatusDTO> > List([FromBody] OrderStatusMaster_OrderStatusFilterDTO OrderStatusMaster_OrderStatusFilterDTO) { if (!ModelState.IsValid) { throw new MessageException(ModelState); } OrderStatusFilter OrderStatusFilter = ConvertFilterDTOToFilterEntity(OrderStatusMaster_OrderStatusFilterDTO); List <OrderStatus> OrderStatuss = await OrderStatusService.List(OrderStatusFilter); return(OrderStatuss.Select(c => new OrderStatusMaster_OrderStatusDTO(c)).ToList()); }
public async Task <List <OrderStatus> > List(OrderStatusFilter filter) { if (filter == null) { return(new List <OrderStatus>()); } IQueryable <OrderStatusDAO> OrderStatusDAOs = DataContext.OrderStatus; OrderStatusDAOs = DynamicFilter(OrderStatusDAOs, filter); OrderStatusDAOs = DynamicOrder(OrderStatusDAOs, filter); var OrderStatuss = await DynamicSelect(OrderStatusDAOs, filter); return(OrderStatuss); }
public static void SaveOrderStatus(string userID, int status, string tabID) { using (var clientCtx = new ClientDbContext()) { var orderstatus = clientCtx.OrderStatusFilter.FirstOrDefault(t => t.AccountID == userID && t.Orderstatus == status && t.TabID == tabID); if (orderstatus == null) { orderstatus = new OrderStatusFilter { AccountID = userID, Orderstatus = status, TabID = tabID, }; clientCtx.OrderStatusFilter.Add(orderstatus); clientCtx.SaveChanges(); } } }
public OrderStatusFilter ConvertFilterDTOToFilterEntity(OrderStatusMaster_OrderStatusFilterDTO OrderStatusMaster_OrderStatusFilterDTO) { OrderStatusFilter OrderStatusFilter = new OrderStatusFilter(); OrderStatusFilter.Selects = OrderStatusSelect.ALL; OrderStatusFilter.Id = new LongFilter { Equal = OrderStatusMaster_OrderStatusFilterDTO.Id }; OrderStatusFilter.Code = new StringFilter { StartsWith = OrderStatusMaster_OrderStatusFilterDTO.Code }; OrderStatusFilter.Name = new StringFilter { StartsWith = OrderStatusMaster_OrderStatusFilterDTO.Name }; OrderStatusFilter.Description = new StringFilter { StartsWith = OrderStatusMaster_OrderStatusFilterDTO.Description }; return(OrderStatusFilter); }
public async Task <bool> ValidateId(OrderStatus OrderStatus) { OrderStatusFilter OrderStatusFilter = new OrderStatusFilter { Skip = 0, Take = 10, Id = new LongFilter { Equal = OrderStatus.Id }, Selects = OrderStatusSelect.Id }; int count = await UOW.OrderStatusRepository.Count(OrderStatusFilter); if (count == 0) { OrderStatus.AddError(nameof(OrderStatusValidator), nameof(OrderStatus.Id), ErrorCode.IdNotExisted); } return(count == 1); }
public static OrdersList GetOrders( string clientId, OrderStatusFilter statusFilter, OrderSortFields sort, int startIndex, int size ) { using( var dc = new DCFactory<StoreDataContext>() ) { DataLoadOptions options = new DataLoadOptions(); options.LoadWith<Order>( o => o.OrderLines ); dc.DataContext.LoadOptions = options; dc.DataContext.Log = new DebugTextWriter(); var orders = dc.DataContext.Orders.Where( o => o.ClientID == clientId ).ToArray().AsQueryable(); //применить фильтры orders = statusFilter == OrderStatusFilter.ActiveOrders ? orders.Where( o => o.Status != OrderStatus.Completed ) : orders.Where( o => o.Status == OrderStatus.Completed ); //применить сортировку switch( sort ) { case OrderSortFields.OrderIdAsc: orders = orders.OrderBy( o => o.OrderID ); break; case OrderSortFields.OrderIdDesc: orders = orders.OrderByDescending( o => o.OrderID ); break; //case OrderSortFields.OrderDateAsc: orders = orders.OrderBy( o => o.OrderDate ); break; //case OrderSortFields.OrderDateDesc: orders = orders.OrderByDescending( o => o.OrderDate ); break; //case OrderSortFields.TotalAsc: orders = orders.OrderBy( o => o.Total ); break; //case OrderSortFields.TotalDesc: orders = orders.OrderByDescending( o => o.Total ); break; case OrderSortFields.Status: orders = orders.OrderBy( o => o.Status ).ThenBy( o => o.OrderID ); break; //case OrderSortFields.StatusDesc: orders = orders.OrderByDescending( o => o.Status ).ThenBy( o => o.OrderID ); break; } OrdersList res = new OrdersList(); res.TotalCount = orders.Count(); res.Orders = orders.Skip( startIndex ).Take( size ).ToArray(); res.StartIndex = startIndex; return res; } }
private IQueryable <OrderStatusDAO> DynamicOrder(IQueryable <OrderStatusDAO> query, OrderStatusFilter filter) { switch (filter.OrderType) { case OrderType.ASC: switch (filter.OrderBy) { case OrderStatusOrder.Id: query = query.OrderBy(q => q.Id); break; case OrderStatusOrder.Code: query = query.OrderBy(q => q.Code); break; case OrderStatusOrder.Name: query = query.OrderBy(q => q.Name); break; case OrderStatusOrder.Description: query = query.OrderBy(q => q.Description); break; } break; case OrderType.DESC: switch (filter.OrderBy) { case OrderStatusOrder.Id: query = query.OrderByDescending(q => q.Id); break; case OrderStatusOrder.Code: query = query.OrderByDescending(q => q.Code); break; case OrderStatusOrder.Name: query = query.OrderByDescending(q => q.Name); break; case OrderStatusOrder.Description: query = query.OrderByDescending(q => q.Description); break; } break; } query = query.Skip(filter.Skip).Take(filter.Take); return(query); }
private IQueryable <OrderStatusDAO> DynamicFilter(IQueryable <OrderStatusDAO> query, OrderStatusFilter filter) { if (filter == null) { return(query.Where(q => false)); } if (filter.Id != null) { query = query.Where(q => q.Id, filter.Id); } if (filter.Code != null) { query = query.Where(q => q.Code, filter.Code); } if (filter.Name != null) { query = query.Where(q => q.Name, filter.Name); } if (filter.Description != null) { query = query.Where(q => q.Description, filter.Description); } if (filter.Ids != null) { query = query.Where(q => filter.Ids.Contains(q.Id)); } if (filter.ExceptIds != null) { query = query.Where(q => !filter.ExceptIds.Contains(q.Id)); } return(query); }
private async Task <List <OrderStatus> > DynamicSelect(IQueryable <OrderStatusDAO> query, OrderStatusFilter filter) { List <OrderStatus> OrderStatuss = await query.Select(q => new OrderStatus() { Id = filter.Selects.Contains(OrderStatusSelect.Id) ? q.Id : default(long), Code = filter.Selects.Contains(OrderStatusSelect.Code) ? q.Code : default(string), Name = filter.Selects.Contains(OrderStatusSelect.Name) ? q.Name : default(string), Description = filter.Selects.Contains(OrderStatusSelect.Description) ? q.Description : default(string), }).ToListAsync(); return(OrderStatuss); }
public async Task <List <OrderStatus> > List(OrderStatusFilter OrderStatusFilter) { List <OrderStatus> OrderStatuss = await UOW.OrderStatusRepository.List(OrderStatusFilter); return(OrderStatuss); }
public async Task <int> Count(OrderStatusFilter OrderStatusFilter) { int result = await UOW.OrderStatusRepository.Count(OrderStatusFilter); return(result); }