public ActionResult Orders() { List <Order> orders = OrderCRUD.GetUserOrders((int)Session["UserID"]); orders.RemoveAll(item => item.OrderStatus == "Delivered"); return(View(orders)); }
public ActionResult PlaceOrder() { Order newOrder = new Order(); newOrder.UserID = (int)Session["UserID"]; newOrder.Items = (List <Tuple <int, int, int> >)Session["OrderItems"]; newOrder.TotalCost = OrderCRUD.CalcTotalCost(newOrder.Items); if (newOrder.Items.Count > 0) { if (OrderCRUD.CreateOrder(newOrder)) { //emptying cart ((List <Tuple <int, int, int> >)Session["OrderItems"]).Clear(); ((List <Tuple <int, int, int> >)Session["OrderItems"]).TrimExcess(); return(Content("<script>alert('Order Placed Successfully.');window.location.href=document.referrer;</script>")); } else { return(Content("<script>alert('Order could not be placed.');window.location.href=document.referrer;</script>")); } } else { return(Content("<script>alert('Cart is empty');window.location.href=document.referrer;</script>")); } }
static async Task Main(string[] args) { var productRepo = new ProductCRUD(); var customerRepo = new CustomerCRUD(); var orderRepo = new OrderCRUD(); var userModels = db.Get(); }
public ActionResult History() { List <Order> AllOrders = OrderCRUD.GetUserOrders((int)Session["UserID"]); List <Request> AllRequests = RequestCRUD.GetRequest((int)Session["UserID"]); AllOrders.RemoveAll(item => item.OrderStatus != "Delivered"); AllRequests.RemoveAll(item => item.RequestStatus != "Resolved"); return(View(new Tuple <List <Order>, List <Request> >(AllOrders, AllRequests))); }
public ActionResult RemoveOrder(int id) { if (OrderCRUD.DeleteOrder(id)) { return(Content("<script>alert('Order Deleted Successfully.');window.location.href=document.referrer;</script>")); } else { return(Content("<script>alert('Order could not be found.');window.location.href=document.referrer</script>")); } }
// GET: Admin public ActionResult Console() { List <Order> AllOrders = OrderCRUD.GetAllOrders(); List <Request> AllRequests = RequestCRUD.GetRequest((int)Session["UserID"]); //pass admin id to get all requests AllOrders.RemoveAll(item => item.OrderStatus == "Delivered"); //only keep undelievered orders AllRequests.RemoveAll(item => item.RequestStatus == "Resolved"); //only keep unresolved requests //display pending work to the admin docking page return(View(new Tuple <List <Order>, List <Request> >(AllOrders, AllRequests))); }
public void BindDataGrid(List <Order> orders) { if (orders == null) { orders = new OrderCRUD().GetOrders(); } if (orders.Count > 0) { List <OrderStatus> orderStatuses = new OrderCRUD().GetOrderStatuses(); List <Job> jobs = new JobCRUD().GetJobs(); foreach (Order ord in orders) { if (ord.OrderStatusId > 0) { if (orderStatuses.Count > 0) { ord.OrderStatusName = orderStatuses.Where(x => x.OrderStatusId == ord.OrderStatusId).First().OrderStatusName; } else { ord.OrderStatusName = "None"; } } else { ord.OrderStatusName = "None"; } if (ord.JobId > 0) { if (jobs.Count > 0) { ord.JobName = jobs.Where(x => x.JobId == ord.JobId).First().Name; } else { ord.JobName = "None"; } } else { ord.JobName = "None"; } } } dgData.ItemsSource = orders; }
public ActionResult UpdateStatus(FormCollection collection) { int oid = Int32.Parse(collection["OrderID"]); string status = collection["OrderStatus"]; if (OrderCRUD.UpdateStatus(oid, status)) { return(Content("<script>alert('Order Status has been Updated Successfully.');window.location.href=document.referrer;</script>")); } else { return(Content("<script>alert('Order Status could not be Updated.');window.location.href=document.referrer</script>")); } }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { Order currentOrder = (Order)this.DataContext; int result = new OrderCRUD().Update(currentOrder); if (result > 0) { this.Close(); MessageBox.Show("Order was updated", "Success"); } else { MessageBox.Show("Failed to update order", "Failure"); } }
public ActionResult DeleteAccount() { List <Order> orders = OrderCRUD.GetUserOrders((int)Session["UserID"]); //if any order exists that hasnt been delievered then cannot delete account if (orders.FindIndex(item => item.OrderStatus != "Delivered") < 0) { AccountCRUD.RemoveUser((int)Session["UserID"]); return(Redirect("Home")); } else { return(Content("<script>alert('You still have pending Orders.');window.location.href=document.referrer</script>")); } }
private void BtnDestroy_Click(object sender, RoutedEventArgs e) { int result = 0; if (GetSelectedOrder().OrderId > 0) { result = new OrderCRUD().Destroy(GetSelectedOrder().OrderId); } if (result > 0) { BindDataGrid(null); } else { MessageBox.Show("Order was deleted", "Success"); } }
public void OrdersSearch(SearchWindow window) { string name = window.TxtSearchOrderName.Text; string price = window.TxtSearchOrderPrice.Text; string quantity = window.TxtSearchOrderQuantity.Text; string statusId = window.CbOrderStatusId.Text; List <Order> order = new OrderCRUD().GetOrders(); if (!String.IsNullOrEmpty(name)) { order.RemoveAll(x => x.Name.ToLower() != name.ToLower()); } if (!String.IsNullOrEmpty(price)) { order.RemoveAll(x => x.Price != Convert.ToDecimal(price)); } if (!String.IsNullOrEmpty(quantity)) { order.RemoveAll(x => x.Quantity != Convert.ToInt32(quantity)); } if (!String.IsNullOrEmpty(statusId)) { order.RemoveAll(x => x.OrderStatusId != Convert.ToInt32(statusId)); } if (order.Count > 0) { BindDataGrid(order); window.Close(); } else { MessageBox.Show("There are no results", "Information"); } }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { Order currentOrder = (Order)this.DataContext; int result = new OrderCRUD().Create(currentOrder); if (result > 0) { if (Convert.ToBoolean(ChkAutoCharge.IsChecked)) { try { Charge newCharge = new Charge() { ChargeAmount = currentOrder.Price, ChargeDescription = "For Order " + currentOrder.Name, ChargeName = "Materials", ChargeNotes = "Created on " + DateTime.Now.ToString(), ChargeQuantity = currentOrder.Quantity, JobId = currentOrder.JobId }; new ChargeCRUD().Create(newCharge); } catch (Exception ex) { throw ex; } } this.Close(); MessageBox.Show("Order was created", "Success"); } else { MessageBox.Show("Failed to create order", "Failure"); } }
public ActionResult OrderDetails(int id) { return(PartialView("_OrderDetails", OrderCRUD.GetOrderItems(id))); }
public ActionResult Order() { List <Order> AllOrders = OrderCRUD.GetAllOrders(); return(View(AllOrders)); }