public string ChangeStatus(int id = 0, int statusID = 0) {
     Profile p = ViewBag.profile;
     Cart order = new Cart();
     order = order.GetByPayment(id);
     order.SetStatus(statusID, p.first + " " + p.last);
     return "success";
 }
 public ActionResult Items(int id = 0) {
     try {
         Cart order = new Cart();
         order = order.GetByPayment(id);
         Customer customer = new Customer{ ID = order.cust_id };
         customer.Get();
         ViewBag.customer = customer;
         ViewBag.order = order;
         ViewBag.statuses = new OrderStatus().GetAll();
     } catch (Exception) {
         return RedirectToAction("Index");
     }
     return View();
 }
 public string GetHistory(int id = 0) {
     Profile profile = ViewBag.profile ?? new Profile();
     TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById(profile.timezone ?? "UTC");
     Cart order = new Cart();
     order = order.GetByPayment(id);
     List<OrderHistoryJSON> histories = new List<OrderHistoryJSON>();
     foreach (OrderHistory history in order.OrderHistories) {
         OrderHistoryJSON jhist = new OrderHistoryJSON {
             ID = history.ID,
             statusID = history.statusID,
             orderID = history.orderID,
             dateAdded = history.dateAdded,
             added = String.Format("{0:M/d/yyyy} {0:h:mm tt}", TimeZoneInfo.ConvertTimeFromUtc(history.dateAdded, tz)),
             changedBy = history.changedBy,
             OrderStatus = history.OrderStatus
         };
         histories.Add(jhist);
     }
     return JsonConvert.SerializeObject(histories);
 }
 public ActionResult Void(int id = 0)
 {
     Cart order = new Cart();
     order = order.GetByPayment(id);
     order.Void();
     return RedirectToAction("Items", new { id = id });
 }
 public string AddShipment(int id, string trackingnum) {
     Cart order = new Cart();
     order = order.GetByPayment(id);
     Shipment shipment = order.AddShipment(trackingnum);
     string trackingcodes = order.Shipments.Select(x => x.tracking_number).Aggregate((i, j) => i + "," + j);
     return trackingcodes;
 }
 public string SendShippingNotification(int id = 0) {
     Cart order = new Cart();
     order = order.GetByPayment(id);
     order.SendShippingNotification();
     return "";
 }
 public ActionResult Void(int id = 0) {
     Profile p = ViewBag.profile;
     Cart order = new Cart();
     order = order.GetByPayment(id);
     order.Void(p.first + " " + p.last);
     return RedirectToAction("Items", new { id = id });
 }
        public ActionResult RegeneratePO(int id = 0) {
            Settings settings = new Settings();
            if (settings.Get("EDIOrderProcessing") == "true") {

                EDI edi = new EDI();
                Cart order = new Cart();
                order = order.GetByPayment(id);
                edi.CreatePurchaseOrder(order.ID);
            }
            return RedirectToAction("Items", new { id = id });
        }
 public string ClearShipments(int id) {
     Cart order = new Cart();
     order = order.GetByPayment(id);
     bool success = order.ClearShipments();
     return JsonConvert.SerializeObject(success);
 }