public async Task <IActionResult> Orders(OrderSearchViewModel data) { try { var orders = await _domainService.Get(data.OrderId, data.UserId, data.StartDate, data.EndDate, data.MinTotal, data.MaxTotal); var viewModelList = orders.Select(x => new OrderResultViewModel { OrderId = x.OrderId, CreationDate = x.CreationDate, OrderItems = x.OrderItems.Select(y => new OrderItemResultViewModel { OrderItemId = y.OrderItemId, ProductId = y.ProductId, Amount = y.Amount, CurrentPrice = y.CurrentPrice }).ToList() }).ToList(); return(new OkObjectResult(viewModelList)); } catch { return(BadRequest("Unable to retrieve orders.")); } }
public IEnumerable <OrderViewModel> GetOrderView(OrderSearchViewModel searchModel, PaginationViewModel page) { IQueryable <OrderViewModel> queryableData = from o in dbContext.Orders join cu in dbContext.Customers on o.CustomerID equals cu.CustomerID join od in dbContext.OrderDetails on o.OrderID equals od.OrderID where (string.IsNullOrEmpty(searchModel.CustomerName) || cu.CustomerName.ToUpper().Contains(searchModel.CustomerName.ToUpper())) && (string.IsNullOrEmpty(searchModel.SKU) || od.SKU.ToUpper().Contains(searchModel.SKU.ToUpper())) select new OrderViewModel { OrderID = o.OrderID, CreateTime = o.CreateTime, CustomerName = cu.CustomerName, Email = cu.Email, OrderItems = dbContext.OrderDetails.Where(a => a.OrderID == o.OrderID), }; page.TotalItems = queryableData.Count(); if (!string.IsNullOrEmpty(searchModel.SortColumn)) { queryableData = queryableData.OrderByField <OrderViewModel>("OrderID", true); queryableData = queryableData.OrderByField <OrderViewModel>(searchModel.SortColumn, true).Skip(page.PageSize * (page.CurrntPage - 1)).Take(page.PageSize);; } else { queryableData = queryableData.OrderByField <OrderViewModel>("OrderID", true).Skip(page.PageSize * (page.CurrntPage - 1)).Take(page.PageSize); } List <OrderViewModel> viewResult = new List <OrderViewModel>(); return(queryableData.AsEnumerable <OrderViewModel>()); }
public ActionResult Index(int?page) { if (TempData["Message"] != null) { ViewBag.Message = TempData["Message"]; } OrderSearchViewModel model = new OrderSearchViewModel(); var res = HttpContext.User.Identity.Name; var user = _iUserService.GetAll().Where(m => m.UserEmailAddress == res).FirstOrDefault(); AssignSessionVariables(user); try { model.TotalCount = _iOrderService.GetAll(SessionWrapper.Get <int>(AppConstant.UserId), SessionWrapper.Get <int>(AppConstant.RoleId)).Count(); var pager = new Pager(model.TotalCount, page); model.lstOrders = _iOrderService.GetAll(SessionWrapper.Get <int>(AppConstant.UserId), SessionWrapper.Get <int>(AppConstant.RoleId)); model.status.FreshOrders = model.lstOrders.Where(m => m.CurrentStatus == 1).Count(); model.status.InProgress = model.lstOrders.Where(m => m.CurrentStatus == 2).Count(); model.status.OutForDelivery = model.lstOrders.Where(m => m.CurrentStatus == 3).Count(); model.status.Delivered = model.lstOrders.Where(m => m.CurrentStatus == 4).Count(); model.status.Returned = model.lstOrders.Where(m => m.CurrentStatus == 5).Count(); model.status.totalOrders = model.TotalCount; model.lstOrders = model.lstOrders .Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList(); model.Pager = pager; return(View(model)); } catch (Exception ex) { ViewBag.Message = helper.GenerateMessage(" " + ex.Message, MessageType.Error); } return(View(model)); }
public static OrderSearchDto ToDto(this OrderSearchViewModel source) { return(new OrderSearchDto { PageNumber = source.PageNumber, PageSize = source.PageSize }); }
public List <OrderSearchResultItem> Search(OrderSearchViewModel viewModel) { Logger.Debug("Order Search - Order Number:" + viewModel.OrderId); return (_orderRepository.GetBySearchCriteria(viewModel.CustomerId, viewModel.OrderId.HasValue ? viewModel.OrderId.ToString() : null, viewModel.StatusId) .Select(MapToResultItem) .OrderByDescending(x => x.OrderId) .ToList()); }
public static OrderSearchViewModel GetValidOrderSearchViewModel(string searchQuery, bool isAdminView) { var vmdl = new OrderSearchViewModel { SearchQuery = searchQuery, IsAdminView = isAdminView }; return(vmdl); }
public ActionResult _List(OrderSearchViewModel model = null, bool isFirst = false) { ViewBag.isFirst = isFirst; ViewBag.CurrentRoleid = currentAccount.RolesId; if (currentAccount.RolesId == (int)RolesEnum.Admin) { var ord = _context.OrderModel.Where(p => p.StatusId != (int)Status.TaoMoi && p.StatusId != (int)Status.Huy); if (model != null) { if (model.CustomerId.HasValue) { ord = ord.Where(p => p.CustomerId == model.CustomerId.Value); } if (model.StatusId.HasValue) { ord = ord.Where(p => p.StatusId == model.StatusId.Value); } if (model.FromDate.HasValue) { ord = ord.Where(p => model.FromDate.Value.CompareTo((p.OrderDate ?? DateTime.Now)) <= 0); } if (model.ToDate.HasValue) { ord = ord.Where(p => model.ToDate.Value.CompareTo((p.OrderDate ?? DateTime.Now)) >= 0); } } return(PartialView(ord.Select(p => new OrderViewModel() { OrderId = p.OrderId, TONTotal = p.TONTotal, OrderDate = p.OrderDate, StatusId = p.StatusId, StatusName = p.StatusModel.StatusName, ConfirmTONTotal = p.ConfirmTONTotal }).OrderByDescending(p => p.OrderId).ToList())); } else { List <OrderViewModel> ord = new List <OrderViewModel>(); ord = _context.OrderModel.Where(p => p.CustomerId == currentCustomer.CustomerId) .Select(p => new OrderViewModel() { OrderId = p.OrderId, TONTotal = p.TONTotal, OrderDate = p.OrderDate, StatusId = p.StatusId, StatusName = p.StatusModel.StatusName, ConfirmTONTotal = p.ConfirmTONTotal }) .OrderByDescending(p => p.OrderId) .ToList(); return(PartialView(ord)); } }
public ActionResult Index(OrderSearchViewModel model) { FillLookups(); if (ModelState.IsValid) { model.HasSessionCriteria = true; OrderSearchData = model; } return(View(model)); }
private void dgvOrderSearch_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { OrderSearchViewModel orderVM = null; if (dgvOrderSearch.SelectedRows.Count > 0) { orderVM = (OrderSearchViewModel)dgvOrderSearch.SelectedRows[0].DataBoundItem; } if (orderVM == null) { return; /*Exit the Function*/ } OrderUpdateForm orderUpdateForm = new OrderUpdateForm(orderVM.CustomerID); orderUpdateForm.ShowDialog(); }
public ActionResult Index(OrderSearchViewModel searchModel, string page) { var pp = new PaginationViewModel { CurrntPage = (string.IsNullOrEmpty(page) || int.Parse(page) == 0) ? 1 : int.Parse(page), PageSize = GlobalConsts.PageSize, }; OrderViewPageViewModel pageModel = new OrderViewPageViewModel { Orders = so.GetOrderViewsAll(searchModel, pp), OrderSearch = searchModel, Pagination = pp, }; return(View(pageModel)); }
private void btnOrderSearch_Click(object sender, EventArgs e) { //Injector for both searches IOrderUtility orderUtil = DependencyInjectorUtility.GetOrdersUtility(); List <Order> AllOrders = orderUtil.GetSalesOrder(); string search = txtOrderSearch.Text; /*************************************Return all orders for blank search*******************************************/ if (search == "") { List <OrderSearchViewModel> osVMCollection = new List <OrderSearchViewModel>(); foreach (Order OrderDTO in AllOrders) { //create new view model object OrderSearchViewModel osVM = new OrderSearchViewModel(OrderDTO); //add to pVMVollection collection osVMCollection.Add(osVM); } //datasource grid view dgvOrderSearch.DataSource = null; dgvOrderSearch.DataSource = osVMCollection; } /*************************************Return orders for GOOD search************************************************/ else { int ordersearch = int.Parse(txtOrderSearch.Text); //good search List <Order> orderSearchResults = orderUtil.OrderSearch(ordersearch); List <OrderSearchViewModel> osNVMCollection = new List <OrderSearchViewModel>(); foreach (Order ordersDTO in orderSearchResults) { //create new view model object OrderSearchViewModel osVM = new OrderSearchViewModel(ordersDTO); //add to psVMVollection collection osNVMCollection.Add(osVM); } dgvOrderSearch.DataSource = null; dgvOrderSearch.DataSource = osNVMCollection; } }
public async Task When_GetOrders_Success() { // ACT: check if the action response is OK and check if orders found var viewModel = new OrderSearchViewModel { }; IncludeViewStateValidation(viewModel, _controller); var result = await _controller.Orders(viewModel); // ASSERT: Return type Assert.IsType <OkObjectResult>(result); var objectResult = result as OkObjectResult; var orders = objectResult.Value as List <OrderResultViewModel>; // ASSERT: Result has orders and the first has 2 order items Assert.NotEmpty(orders); Assert.Equal(2, orders.First().OrderItems.Count); }
public ActionResult List(OrderSearchViewModel model) { if (ModelState.IsValid) { int pageIndex = model.Page ?? 1; string sql = "SELECT TOP 100 MIN(sip_RECno) AS KayitNo /* Ä°LK KAYIT NO */ , sip_evrakno_seri AS EvrakSeri /* SERÄ° */ , sip_evrakno_sira AS EvrakNo /* SIRA NO */ , sip_tarih AS SiparisTarihi /* SÄ°PARÄ°Åž TARÄ°HÄ° */ , MIN(sip_teslim_tarih) AS TeslimTarihi /* TESLÄ°M TARÄ°HÄ° */ , dbo.fn_TalepTemin(sip_tip) AS Tipi /* TÄ°PÄ° */ , dbo.fn_SiparisCins(sip_cins) AS SiparisCinsi /* SÄ°PARÄ°Åž CÄ°NSÄ° */ , sip_musteri_kod AS CariKodu /* CARÄ° KODU */ , dbo.fn_CarininIsminiBul(0,sip_musteri_kod) AS CariIsmi /* CARÄ° Ä°SMÄ° */ , SUM(sip_miktar) AS Miktar /* MÄ°KTAR */, SUM( dbo.fn_SiparisNetTutar ( sip_tutar, sip_iskonto_1, sip_iskonto_2, sip_iskonto_3, sip_iskonto_4, sip_iskonto_5, sip_iskonto_6, sip_masraf_1, sip_masraf_2, sip_masraf_3, sip_masraf_4, sip_vergi, sip_masvergi, sip_Otv_Vergi, sip_otvtutari, sip_vergisiz_fl, 2,sip_doviz_kuru,sip_alt_doviz_kuru)) AS Tutar, COUNT(sip_satirno) AS SatirSayisi /* SATIR SAYISI */ FROM dbo.SIPARISLER WITH (NOLOCK) Where sip_musteri_kod like '%" + model.CariKod + "%' and sip_tarih BETWEEN '" + model.startDate + "' and '" + model.endDate + "' GROUP BY sip_tip, sip_cins, sip_evrakno_seri, sip_evrakno_sira, sip_tarih, sip_musteri_kod ORDER BY sip_tarih"; viewSiparisORM sip = new viewSiparisORM(); var data = sip.GetList(sql).OrderByDescending(x => x.EvrakNo).OrderByDescending(x => x.SiparisTarihi).ToList(); List <OrderListViewModel> orderlist = new List <OrderListViewModel>(); foreach (var item in data) { OrderListViewModel order = new OrderListViewModel(); order.CariIsmi = item.CariIsmi; order.CariKodu = item.CariKodu; order.EvrakNo = item.EvrakNo; order.EvrakSeri = item.EvrakSeri; order.KalanMiktar = item.KalanMiktar; order.KayitNo = item.KayitNo; order.Miktar = item.Miktar; order.SatirSayisi = item.SatirSayisi; order.SiparisCinsi = item.SiparisCinsi; order.SiparisTarihi = item.SiparisTarihi; order.TeslimTarihi = item.TeslimTarihi; order.Tipi = item.Tipi; order.Tutar = item.Tutar; orderlist.Add(order); } model.OrderList = orderlist.ToPagedList(pageIndex, 10); if (Request.IsAjaxRequest()) { return(PartialView("_orderlist", model)); } return(View(model)); } return(View(model)); }
public List <RoomViewModel> FillRooms([FromBody] OrderSearchViewModel orderSearchViewModel) { IOrderService orderService = new OrderService(); List <RoomViewModel> ResultViewModels = new List <RoomViewModel>(orderSearchViewModel.RoomViewModels); for (int i = 0; i < orderSearchViewModel.RoomViewModels.Count; i++) { RoomDTO roomDTO = configsGenerator.ViewModelToRoomDTO().Map <RoomDTO>(orderSearchViewModel.RoomViewModels[i]); List <OrderDTO> foundedOrders = orderService.GetActiveOrders(orderSearchViewModel.DesiredDateTime, roomDTO); for (int j = 0; j < foundedOrders.Count; j++) { OrderViewModel viewModel = configsGenerator.DTOToOrderViewModel().Map <OrderViewModel>(foundedOrders[j]); if (ResultViewModels[i].RoomOrders == null) { ResultViewModels[i].RoomOrders = new List <OrderViewModel>(); } ResultViewModels[i].RoomOrders.Add(viewModel); } } return(ResultViewModels); }
public IActionResult PostSearchOrders([FromBody] OrderSearchViewModel orderSearchVmdl) { try { var result = orderSearchVmdl.Seach(_bl) .Select(i => new OrderViewModel(i)) .ToList(); var count = result.Count; return(Ok(new OrderListViewModel(result.Skip(orderSearchVmdl.Offset).Take(orderSearchVmdl.Limit), orderSearchVmdl.Limit, count))); } catch (SecurityException) { _log.LogWarning("Security: '{0}' tried to view Orders as Admin/Verwalter'", _bl.GetCurrentUid()); return(Unauthorized()); } catch (Exception ex) { _log.LogError("Exception: '{0}'", ex); return(StatusCode(500)); } }
public List <OrderSearchResultItem> Search(OrderSearchViewModel viewModel) { Logger.Debug("Order Search - Order Number:" + viewModel.OrderId); viewModel.CustomerName = viewModel.CustomerName ?? ""; var result = _orderRepository .GetBySearchCriteria(viewModel.CustomerId, viewModel.OrderId, viewModel.StatusId, viewModel.CustomerType) .Select(order => new OrderSearchResultItem { OrderId = order.Id, CustomerName = order.Customer.Name, StatusName = order.Status.Name, RequestedProcessDate = order.RequestedProcessDate }) .OrderByDescending(x => x.OrderId) .ToList(); result = result.Where( x => x.CustomerName != null && x.CustomerName.ToLowerInvariant().StartsWith(viewModel.CustomerName.ToLowerInvariant())) .ToList(); return(result); }
public ActionResult Index(OrderSearchViewModel input) { int orderId; try { orderId = this.coder.Decode(input.UserInput); } catch (Exception) { input.Result = "Incorrect code"; return this.View(input); } var order = this.orderService.GetById(orderId); if (order == null) { this.ModelState.AddModelError("UserInput", "Such order can not be found"); input.Result = "Such order can not be found"; return this.View(input); } if (order.OrderPublicId != input.UserInput) { input.Result = "Incorrect code"; this.ModelState.AddModelError("UserInput", "Code is not correct"); return this.View(input); } if (!this.ModelState.IsValid) { return this.View(input); } var model = this.Mapper.Map<OrderStatusViewModel>(order); return this.View("OrderStatus", model); }
public SessionUser() { CustomerSearchViewModel = new CustomerSearchViewModel(); OrderSearchViewModel = new OrderSearchViewModel(); ProductSearchViewModel = new ProductSearchViewModel(); }
public IActionResult Index(OrderSearchViewModel searchModel) { var data = _adminService.GetOrders(searchModel.ToDto()); return(View_Search(searchModel, data.ToViewModel())); }
public static Response OrderSearchQuery(QueryUserType type, OrderSearchViewModel model) { var param = new List <SqlParameter>(); var paramCount = new List <SqlParameter>(); var countQuery = "SELECT COUNT(*) FROM ( SELECT DISTINCT [O].[Id] "; var query = @" SELECT DISTINCT [O].[Id], [O].[OrderNumber], [O].[OrderSerial], ( SELECT COUNT(*) FROM [order].[OrderDetail] AS [SOD] INNER JOIN [Products] AS [SP] ON [SP].[Id] = [SOD].[ProductId] WHERE [SOD].[OrderId] = [O].[Id] "; if (type == QueryUserType.LeatherProduct) { query += @" AND ([SP].[WorkshopId2] = 5 OR [SP].[ProductType] IN (10, 15, 14)) "; } else if (type == QueryUserType.NotLeatherProduct) { query += @" AND (([SP].[WorkshopId2] IS NULL OR [SP].[WorkshopId2] != 5) AND [SP].[ProductType] NOT IN (10, 15, 14))"; } query += @" ) AS [sumCount], ( SELECT COUNT(DISTINCT [SOD].[SetNumber]) FROM [order].[OrderDetail] AS [SOD] INNER JOIN [Products] AS [SP] ON [SP].[Id] = [SOD].[ProductId] WHERE [SOD].[OrderId] = [O].[Id] AND [SOD].[SetNumber] IS NOT NULL "; if (type == QueryUserType.LeatherProduct) { query += @" AND ([SP].[WorkshopId2] = 5 OR [SP].[ProductType] IN (10, 15, 14)) "; } else if (type == QueryUserType.NotLeatherProduct) { query += @" AND (([SP].[WorkshopId2] IS NULL OR [SP].[WorkshopId2] != 5) AND [SP].[ProductType] NOT IN (10, 15, 14))"; } query += @" ) AS [sumCountSet], ( SELECT ROUND(SUM([SP].[Weight] * [SOD].[Count]), 2) FROM [order].[OrderDetail] AS [SOD] INNER JOIN [Products] [SP] ON [SP].[Id] = [SOD].[ProductId] WHERE [SOD].[OrderId] = [O].[Id]" ; if (type == QueryUserType.LeatherProduct) { query += @" AND ([SP].[WorkshopId2] = 5 OR [SP].[ProductType] IN (10, 15, 14)) "; } else if (type == QueryUserType.NotLeatherProduct) { query += @" AND (([SP].[WorkshopId2] IS NULL OR [SP].[WorkshopId2] != 5) AND [SP].[ProductType] NOT IN (10, 15, 14))"; } query += @" ) AS [sumWeight], [O].[BranchId] AS [BranchId], [B].[Name] AS [createBranch], [U].[FirstName] + ' ' + [U].[LastName] AS [createUser], [O].[createDate], ( CASE WHEN ( SELECT COUNT(*) FROM [order].[OrderDetail] AS [SOD] INNER JOIN [Products] [SP] ON [SP].[Id] = [SOD].[ProductId] WHERE [SOD].[OrderId] = [O].[Id]" ; if (type == QueryUserType.LeatherProduct) { query += @" AND ([SP].[WorkshopId2] = 5 OR [SP].[ProductType] IN (10, 15, 14)) "; } else if (type == QueryUserType.NotLeatherProduct) { query += @" AND (([SP].[WorkshopId2] IS NULL OR [SP].[WorkshopId2] != 5) AND [SP].[ProductType] NOT IN (10, 15, 14))"; } query += @" ) = ( SELECT COUNT(*) FROM [order].[OrderDetail] AS [SOD] INNER JOIN [Products] [SP] ON [SP].[Id] = [SOD].[ProductId] WHERE [SOD].[OrderId] = [O].[Id] AND [SOD].[OrderDetailStatus] IN (0) " ; if (type == QueryUserType.LeatherProduct) { query += @" AND ([SP].[WorkshopId2] = 5 OR [SP].[ProductType] IN (10, 15, 14)) "; } else if (type == QueryUserType.NotLeatherProduct) { query += @" AND (([SP].[WorkshopId2] IS NULL OR [SP].[WorkshopId2] != 5) AND [SP].[ProductType] NOT IN (10, 15, 14))"; } query += @" ) THEN 'bg-new-order' WHEN ( SELECT COUNT(*) FROM [order].[OrderDetail] AS [SOD] INNER JOIN [Products] [SP] ON [SP].[Id] = [SOD].[ProductId] WHERE [SOD].[OrderId] = [O].[Id] " ; if (type == QueryUserType.LeatherProduct) { query += @" AND ([SP].[WorkshopId2] = 5 OR [SP].[ProductType] IN (10, 15, 14)) "; } else if (type == QueryUserType.NotLeatherProduct) { query += @" AND (([SP].[WorkshopId2] IS NULL OR [SP].[WorkshopId2] != 5) AND [SP].[ProductType] NOT IN (10, 15, 14))"; } query += @" ) = ( SELECT COUNT(*) FROM [order].[OrderDetail] AS [SOD] INNER JOIN [Products] [SP] ON [SP].[Id] = [SOD].[ProductId] WHERE [SOD].[OrderId] = [O].[Id] AND [SOD].[OrderDetailStatus] IN (6, 9, 8) " ; if (type == QueryUserType.LeatherProduct) { query += @" AND ([SP].[WorkshopId2] = 5 OR [SP].[ProductType] IN (10, 15, 14)) "; } else if (type == QueryUserType.NotLeatherProduct) { query += @" AND (([SP].[WorkshopId2] IS NULL OR [SP].[WorkshopId2] != 5) AND [SP].[ProductType] NOT IN (10, 15, 14))"; } query += @" ) THEN 'bg-done-order' WHEN ( SELECT COUNT(*) FROM [order].[OrderDetail] AS [SOD] INNER JOIN [Products] [SP] ON [SP].[Id] = [SOD].[ProductId] WHERE [SOD].[OrderId] = [O].[Id] " ; if (type == QueryUserType.LeatherProduct) { query += @" AND ([SP].[WorkshopId2] = 5 OR [SP].[ProductType] IN (10, 15, 14)) "; } else if (type == QueryUserType.NotLeatherProduct) { query += @" AND (([SP].[WorkshopId2] IS NULL OR [SP].[WorkshopId2] != 5) AND [SP].[ProductType] NOT IN (10, 15, 14))"; } query += @" ) = ( SELECT COUNT(*) FROM [order].[OrderDetail] AS [SOD] INNER JOIN [Products] [SP] ON [SP].[Id] = [SOD].[ProductId] WHERE [SOD].[OrderId] = [O].[Id] AND [SOD].[OrderDetailStatus] IN (6, 7, 8, 9) " ; if (type == QueryUserType.LeatherProduct) { query += @" AND ([SP].[WorkshopId2] = 5 OR [SP].[ProductType] IN (10, 15, 14)) "; } else if (type == QueryUserType.NotLeatherProduct) { query += @" AND (([SP].[WorkshopId2] IS NULL OR [SP].[WorkshopId2] != 5) AND [SP].[ProductType] NOT IN (10, 15, 14))"; } query += @" ) THEN 'bg-open-shortage-order' ELSE 'bg-open-order' END ) AS [bgColor]" ; query += @" FROM [order].[Order] AS [O] INNER JOIN [Branches] AS [B] ON [B].[Id] = [O].[BranchId] INNER JOIN [UserProfile] AS [U] ON [U].[Id] = [O].[CreateUserId] INNER JOIN [order].[OrderDetail] AS [OD] ON [OD].[OrderId] = [O].[Id] INNER JOIN [Products] AS [P] ON [P].[Id] = [OD].[ProductId] WHERE [O].[Deleted] = 0 "; countQuery += @" FROM [order].[Order] AS [O] INNER JOIN [Branches] AS [B] ON [B].[Id] = [O].[BranchId] INNER JOIN [UserProfile] AS [U] ON [U].[Id] = [O].[CreateUserId] INNER JOIN [order].[OrderDetail] AS [OD] ON [OD].[OrderId] = [O].[Id] INNER JOIN [Products] AS [P] ON [P].[Id] = [OD].[ProductId] WHERE [O].[Deleted] = 0 "; if (type == QueryUserType.LeatherProduct) { query += @" AND ([P].[WorkshopId2] = 5 OR [P].[ProductType] = 10 OR [P].[ProductType] = 15 OR [P].[ProductType] = 14) "; countQuery += @" AND ([P].[WorkshopId2] = 5 OR [P].[ProductType] = 10 OR [P].[ProductType] = 15 OR [P].[ProductType] = 14) "; } else if (type == QueryUserType.NotLeatherProduct) { query += @" AND (([P].[WorkshopId2] IS NULL OR [P].[WorkshopId2] != 5) AND [P].[ProductType] NOT IN (10, 15, 14)) "; countQuery += @" AND (([P].[WorkshopId2] IS NULL OR [P].[WorkshopId2] != 5) AND [P].[ProductType] NOT IN (10, 15, 14)) "; } if (model.branchType != null) { query += @" AND [B].[BranchType] = @BranchType "; countQuery += @" AND [B].[BranchType] = @BranchType "; param.Add(new SqlParameter("@BranchType", model.branchType)); paramCount.Add(new SqlParameter("@BranchType", model.branchType)); } if (!string.IsNullOrEmpty(model.date)) { var date = DateUtility.GetDateTime(model.date); query += @" AND ([O].[CreateDate] >= @Date AND [O].[CreateDate] < DATEADD(DAY, 1, @Date)) "; countQuery += @" AND ([O].[CreateDate] >= @Date AND [O].[CreateDate] < DATEADD(DAY, 1, @Date)) "; param.Add(new SqlParameter("@Date", date)); paramCount.Add(new SqlParameter("@Date", date)); } if (model.branchId != null && model.branchId.Count > 0) { query += @" AND [O].[BranchId] IN (SELECT VALUE FROM STRING_SPLIT(@BranchId, '-')) "; countQuery += @" AND [O].[BranchId] IN (SELECT VALUE FROM STRING_SPLIT(@BranchId, '-')) "; param.Add(new SqlParameter("@BranchId", string.Join("-", model.branchId))); paramCount.Add(new SqlParameter("@BranchId", string.Join("-", model.branchId))); } if (!string.IsNullOrEmpty(model.term?.Trim())) { model.term = model.term.ToStandardPersian(); query += @" AND ( [O].[OrderSerial] LIKE @Term OR [O].[OrderNumber] LIKE @Term OR [B].[Name] LIKE @Term OR [B].[Alias] LIKE @Term OR [OD].[Customer] LIKE @Term OR [OD].[PhoneNumber] LIKE @Term OR [OD].[Description] LIKE @Term) " ; param.Add(new SqlParameter("@Term", "%" + model.term + "%")); countQuery += @" AND ( [O].[OrderSerial] LIKE @Term OR [O].[OrderNumber] LIKE @Term OR [B].[Name] LIKE @Term OR [B].[Alias] LIKE @Term OR [OD].[Customer] LIKE @Term OR [OD].[PhoneNumber] LIKE @Term OR [OD].[Description] LIKE @Term) " ; paramCount.Add(new SqlParameter("@Term", "%" + model.term + "%")); } query += @" ORDER BY [O].[OrderNumber] DESC OFFSET @Skip ROWS FETCH NEXT @Take ROWS ONLY; "; param.Add(new SqlParameter("@Skip", model.page * model.count)); param.Add(new SqlParameter("@Take", model.count)); countQuery += " ) AS A "; using (var db = new KiaGalleryContext()) { var total = db.Database.SqlQuery <int>(countQuery, paramCount.ToArray()).First(); var result = db.Database.SqlQuery <OrderQueryViewModel>(query, param.ToArray()).ToList(); result.ForEach(x => { x.persianDate = DateUtility.GetPersianDate(x.createDate); }); var response = new Response() { status = 200, data = new { list = result, pageCount = Math.Ceiling((double)total / model.count), count = total, page = model.page + 1, } }; return(response); } }
public ActionResult Reset() { OrderSearchData = new OrderSearchViewModel(); return(RedirectToAction("Index")); }
public ActionResult Search(string orderNo, string consignneName, string agentName, Double?consgnNo, string date, string daterange, int?orderType, int?page, int pageSize) { if (pageSize > 0 && pageSize <= 10) { pageSize = 10; } else if (pageSize > 10 && pageSize <= 50) { pageSize = 50; } else if (pageSize > 50 && pageSize <= 100) { pageSize = 100; } else if (pageSize > 100 && pageSize <= 500) { pageSize = 500; } else if (pageSize > 500 && pageSize <= 1000) { pageSize = 1000; } else if (pageSize > 1000 && pageSize <= 10000) { pageSize = 10000; } else if (pageSize > 10000 && pageSize <= 100000) { pageSize = 100000; } OrderSearchViewModel model = new OrderSearchViewModel(); string[] dates = daterange.Split('-'); DateTime from = DateTime.ParseExact(dates[0].TrimEnd(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture); DateTime to = DateTime.ParseExact(dates[1].TrimStart(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture); model.lstOrders = _iOrderService.GetAll(SessionWrapper.Get <int>(AppConstant.UserId), SessionWrapper.Get <int>(AppConstant.RoleId)).ToList(); if (orderNo != null && !String.IsNullOrEmpty(orderNo)) { model.lstOrders = model.lstOrders.Where(x => x.OrderNo != null); model.lstOrders = model.lstOrders.Where(x => x.OrderNo.ToString().Contains(orderNo)); } if (consignneName != null && !String.IsNullOrEmpty(consignneName)) { model.lstOrders = model.lstOrders.Where(x => x.ConsigneeName.ToString().ToUpper().Contains(consignneName.ToUpper())); } if (agentName != null && !String.IsNullOrEmpty(agentName)) { model.lstOrders = model.lstOrders.Where(x => x.AgentName.ToString().ToUpper().Contains(agentName.ToUpper())); } if (consgnNo != null && consgnNo != 0) { model.lstOrders = model.lstOrders.Where(x => x.ConsigneeNumber.ToString().Contains(consgnNo.ToString())); } if (date != null && !String.IsNullOrEmpty(date)) { DateTime myDate = DateTime.ParseExact(date, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture); model.lstOrders = model.lstOrders.Where(x => x.Date == myDate); } if (daterange != null && !String.IsNullOrEmpty(daterange) && from != DateTime.Now.Date && to != DateTime.Now.Date) { model.lstOrders = model.lstOrders.Where(x => x.Date >= from && x.Date <= to); } model.status.totalOrders = model.lstOrders.Count(); model.status.FreshOrders = model.lstOrders.Where(m => m.CurrentStatus == 1).Count(); model.status.InProgress = model.lstOrders.Where(m => m.CurrentStatus == 2).Count(); model.status.OutForDelivery = model.lstOrders.Where(m => m.CurrentStatus == 3).Count(); model.status.Delivered = model.lstOrders.Where(m => m.CurrentStatus == 4).Count(); model.status.Returned = model.lstOrders.Where(m => m.CurrentStatus == 6).Count(); if (orderType != null) { model.lstOrders = model.lstOrders.Where(x => x.CurrentStatus == orderType); } model.TotalCount = model.lstOrders.Count(); var pager = new Pager(model.TotalCount, page, pageSize); model.lstOrders = model.lstOrders.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList(); model.Pager = pager; return(PartialView("_OrdersList", model)); }
public void MakeOrder(ActivityViewModel interestedActivity, DateTime DesiredDateTime) { List <RoomViewModel> PosibleRooms = interestedActivity.PosibleRooms; OrderSearchViewModel orderSearchViewModel = new OrderSearchViewModel() { DesiredDateTime = DesiredDateTime, RoomViewModels = PosibleRooms }; var content = new StringContent(JsonConvert.SerializeObject(orderSearchViewModel), Encoding.UTF8, "application/json"); HttpResponseMessage httpResponse = HttpClient.PostAsync(URL + "Rooms/FillRooms", content).Result; PosibleRooms = JsonConvert.DeserializeObject <List <RoomViewModel> >(httpResponse.Content.ReadAsStringAsync().Result); for (int i = 0; i < PosibleRooms.Count; i++) { Console.WriteLine("Room ID: " + PosibleRooms[i].Id + " Room Name: " + PosibleRooms[i].Name); if (PosibleRooms[i].RoomOrders != null) { var posibleOrders = PosibleRooms[i].RoomOrders; for (int j = 0; j < posibleOrders.Count; j++) { Console.WriteLine(" OrderID: " + posibleOrders[j].Id + " StartTime: " + posibleOrders[j].StartDate.ToString("HH:mm") + " EndTime: " + posibleOrders[j].StartDate.AddHours(posibleOrders[j].Hours).ToString("HH:mm")); } } } Console.WriteLine("\nEnter Rooms ID, Start Hour and Hours to spend.\nFormat[RoomId1,RoomId2.StartHour;AmountOfHoursToSpend].\nExample: 7,9.15;3 - Order rooms with id 7 and 9. Beginning at 15:00. Lasting 3 hours.\nDon't forget we work between 08:00 - 00:00 every day)\n"); string[] IdsStartTimeHours = Console.ReadLine().Split(';'); int Hours = Convert.ToInt32(IdsStartTimeHours[1]); string[] IdsStartTime = IdsStartTimeHours[0].Split('.'); int StartHour = Convert.ToInt32(IdsStartTime[1]); string[] RoomIdStrings = IdsStartTime[0].Split(','); Console.WriteLine("Enter your name: "); string clientName = Console.ReadLine(); Console.WriteLine("Enter your surname: "); string clientSurname = Console.ReadLine(); DateTime FinaDateTime = DesiredDateTime; FinaDateTime = FinaDateTime.AddHours(StartHour); List <RoomViewModel> UserOrderedRoom = new List <RoomViewModel>(); for (int i = 0; i < RoomIdStrings.Length; i++) { int curId = Convert.ToInt32(RoomIdStrings[i]); RoomViewModel room = PosibleRooms.Where(r => r.Id == curId).FirstOrDefault(); if (room != null) { UserOrderedRoom.Add(room); } } OrderViewModel newOrder = new OrderViewModel() { Name = clientName, Surname = clientSurname, Hours = Hours, StartDate = FinaDateTime, OrderedRooms = UserOrderedRoom }; var content2 = new StringContent(JsonConvert.SerializeObject(newOrder), Encoding.UTF8, "application/json"); HttpResponseMessage httpResponseMessage = HttpClient.PostAsync(URL + "api/Orders/", content2).Result; OrderViewModel CreatedOrder = JsonConvert.DeserializeObject <OrderViewModel>(httpResponseMessage.Content.ReadAsStringAsync().Result); if (CreatedOrder != null) { if (interestedActivity.PricePerHour != 0) { Console.WriteLine($"Your order was successfully added. Order Id: {CreatedOrder.Id} You have to pay " + interestedActivity.PricePerHour * Hours * UserOrderedRoom.Count + ". Waiting for you at agreed date"); } else { Console.WriteLine("Your order was succesfully added. Our manager will call you to talk about the price."); } } else { Console.WriteLine("Invalid Time Option"); } Console.ReadLine(); }
public IEnumerable <OrderViewModel> GetOrderViewsAll(OrderSearchViewModel searchModel, PaginationViewModel page) { return(repo.GetOrderView(searchModel, page)); }