Beispiel #1
0
        public async System.Threading.Tasks.Task <ActionResult> ChangeState(int id)
        {
            Order order = new Order();

            using (App_Context db = new App_Context())
            {
                order = db.Orders.SingleOrDefault(s => s.OrderId == id);
                if (order == null || order.OrderState != "Pending" && order.OrderState != "Read" && order.OrderState != "Completed")
                {
                    return(HttpNotFound());
                }
                if (order.OrderState == "Completed")
                {
                    order.OrderState = "Read";
                }
                else
                {
                    order.OrderState = "Completed";
                    EmailHandler e = new EmailHandler();
                    await e.CompletedEmail(order);
                }
                db.SaveChanges();
            }
            return(RedirectToAction("Order", "Order"));
        }