public async Task <GetOrdersResponseModel> GetOrdersList() { try { List <Order> ordersList = await _orderRepository.GetOrdersList(); var result = new GetOrdersResponseModel(); foreach (var order in ordersList) { var orderModel = new GetOrdersResponseItem() { Name = order.Name, CreationDate = order.CreationDate.ToShortDateString(), Id = order.Id, Status = order.Status.ToString() }; result.Orders.Add(orderModel); } return(result); } catch (Exception exception) { Console.WriteLine(exception); return(new GetOrdersResponseModel()); } }
public static GetOrdersResponseModel GetOrdersWaitingForPickup(GetOrdersListRequestModel requestModel) { using (var dbContext = new DeliversEntities()) { requestModel.CurrentPage--; var response = new GetOrdersResponseModel(); var list = dbContext.Orders .Where( od => od.OrderHistories.Any(str => str.Status == OrderHistoryEnu.WaitingForPickup.Value)) .ToList(); //&& //(string.IsNullOrEmpty(requestModel.SearchTerm) || //(od.OrderDetails.Any(det => det.ItemDetail.ListItem.Name.ToLower().Contains(requestModel.SearchTerm.ToLower())) && //od.OrderHistories.Count == 1 && od.OrderHistories.Any(str => str.Status == (int)OrderHistoryEnum.WaitingForPickup)))).ToList(); if (list.Any()) { var take = list.Skip(requestModel.CurrentPage * requestModel.ItemsPerPage). Take(requestModel.ItemsPerPage).ToList(); if (take.Any()) { var finals = take.Select(obj => obj.MappOrderWaitingForPickup()).ToList(); response.Orders = finals; } } response.ItemsPerPage = requestModel.ItemsPerPage; response.CurrentPage++; response.TotalItems = list.Count; return(response); } }
public EbayOrdersListModel(GetOrdersResponseModel data, int page, int perPage) { Total = data.total; Page = page; Orders = data.orders.Select(x => new EbayOrdersListItemModel(x)); Pagination = new PaginationModel(data.total, page, perPage); }
public static GetOrdersResponseModel OrdersReadyToAssign(GetOrdersListRequestModel requestModel) { using (var dbContext = new DeliversEntities()) { requestModel.CurrentPage--; var response = new GetOrdersResponseModel(); var list = dbContext.Orders .Where( od => od.Status == OrderHistoryEnu.ConfirmedByRestaurant.Value && od.OrderHistories.Any(str => str.Status == OrderHistoryEnu.ConfirmedByRestaurant.Value && str.IsCurrent)) .ToList(); DbGeography riderLoc = null; List <string> latlng = new List <string>(); if (!string.IsNullOrEmpty(requestModel.Cords) && requestModel.Cords != "") { latlng = requestModel.Cords.Split('_').ToList(); if (latlng.Count == 2) { riderLoc = CommonService.ConvertLatLonToDbGeography(latlng[1], latlng[0]); // lat _ lng } } var inRangeOrders = new List <Order>(); if (list != null && list.Any()) { foreach (var o in list) { var dist = CommonService.GetDistance((double)riderLoc.Latitude, (double)riderLoc.Longitude, Convert.ToDouble(o.Cords.Latitude), Convert.ToDouble(o.Cords.Longitude)); //if ((int)dist < Convert.ToInt16(10)) { inRangeOrders.Add(o); } } } if (inRangeOrders.Any()) { var take = list.Skip(requestModel.CurrentPage * requestModel.ItemsPerPage). Take(requestModel.ItemsPerPage).ToList(); if (take.Any()) { var finals = take.Select(obj => obj.MappOrderWaitingForPickup()).ToList(); response.Orders = finals; } } response.ItemsPerPage = requestModel.ItemsPerPage; response.CurrentPage++; response.TotalItems = list.Count; return(response); } }
public OrdersModel(GetOrdersResponseModel model, string status) { Orders = model.data.Select(x => new OrderModel(x)).ToList(); Status = status; }
public List <GetOrdersResponseModel> getOrders(GetOrdersRequestModel getOrdersRequestModel, out ErrorModel errorModel) { errorModel = null; List <GetOrdersResponseModel> orders = null; SqlConnection connection = null; try { using (connection = new SqlConnection(Database.getConnectionString())) { SqlCommand command = new SqlCommand(SqlCommands.SP_getOrders, connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("chefOrCashier", getOrdersRequestModel.chefOrCashier); command.Parameters.AddWithValue("customer_id", getOrdersRequestModel.customerId); command.Parameters.AddWithValue("fromDate", getOrdersRequestModel.fromDate); command.Parameters.AddWithValue("toDate", getOrdersRequestModel.toDate); command.Parameters.AddWithValue("email", getOrdersRequestModel.email); command.Parameters.AddWithValue("needUnpaidOnly", getOrdersRequestModel.needUnpaidOnly); connection.Open(); orders = new List <GetOrdersResponseModel>(); SqlDataReader reader = command.ExecuteReader(); GetOrdersResponseModel getOrdersResponseModel = null; int orderIdCheck = 0; while (reader.Read()) { MenuItems menuItems = new MenuItems(); if (orderIdCheck != Convert.ToInt32(reader["orderId"].ToString())) { if (orderIdCheck != 0) { orders.Add(getOrdersResponseModel); } getOrdersResponseModel = new GetOrdersResponseModel(); getOrdersResponseModel.menuItems = new List <MenuItems>(); getOrdersResponseModel.orderId = Convert.ToInt32(reader["orderId"].ToString()); getOrdersResponseModel.orderDate = reader["orderDate"].ToString(); getOrdersResponseModel.isDiningIn = Convert.ToBoolean(reader["isDiningIn"].ToString()); getOrdersResponseModel.orderStatusTitle = reader["orderStatusTitle"].ToString(); getOrdersResponseModel.billingAmount = Convert.ToDouble(reader["billingAmount"].ToString()); getOrdersResponseModel.isCardPayment = Convert.ToBoolean(reader["isCardPayment"].ToString()); getOrdersResponseModel.firstName = reader["FirstName"].ToString(); getOrdersResponseModel.lastName = reader["lastName"].ToString(); getOrdersResponseModel.statusId = Convert.ToInt32(reader["orderStatusId"].ToString()); getOrdersResponseModel.isPaid = Convert.ToBoolean(reader["isPaid"].ToString()); getOrdersResponseModel.billId = Convert.ToInt32(reader["billId"].ToString()); getOrdersResponseModel.GST = Convert.ToDecimal(reader["gst"].ToString()); getOrdersResponseModel.PST = Convert.ToDecimal(reader["pst"].ToString()); getOrdersResponseModel.totalAfterTax = Convert.ToDecimal(reader["totalAfterTax"].ToString()); getOrdersResponseModel.tip = Convert.ToDecimal(reader["tip"].ToString()); getOrdersResponseModel.isReadyToPay = Convert.ToBoolean(reader["isReadyToPay"].ToString()); int temp = 0; int.TryParse(reader["tableId"].ToString(), out temp); if (temp != 0) { getOrdersResponseModel.tableId = Convert.ToInt32(reader["tableId"].ToString()); } orderIdCheck = getOrdersResponseModel.orderId; } menuItems.itemName = reader["itemName"].ToString(); menuItems.itemQty = Convert.ToInt32(reader["itemQty"].ToString()); menuItems.itemDescription = reader["itemDescription"].ToString(); menuItems.itemPrice = Convert.ToDouble(reader["price"].ToString()); menuItems.category = reader["categoryTitle"].ToString(); getOrdersResponseModel.menuItems.Add(menuItems); } if (getOrdersResponseModel != null) { orders.Add(getOrdersResponseModel); } command.Dispose(); } return(orders); } catch (Exception e) { errorModel = new ErrorModel(); errorModel.ErrorMessage = e.Message; return(null); } finally { if (connection != null) { connection.Close(); } } }