Example #1
0
        public ActionResult Create(Order model)
        {
            if (model.CustomerID == null)
            {
                ModelState.AddModelError("CustomerID", "CustomerID Expected");
            }
            if (model.ShipAddress == null)
            {
                ModelState.AddModelError("ShipAddress", "ShipAddress Expected");
            }
            if (model.RequiredDate.CompareTo(DateTime.UtcNow) > 0)
            {
                ModelState.AddModelError("RequiredDate", "RequiredDate Expected");
            }
            if (model.ShippeDate.CompareTo(DateTime.UtcNow) > 0)
            {
                ModelState.AddModelError("ShippeDate", "ShippeDate Expected");
            }
            if (model.ShipCity == null)
            {
                ModelState.AddModelError("ShipCity", "ShipCity Expected");
            }
            if (model.ShipCountry == null)
            {
                ModelState.AddModelError("ShipCountry", "ShipCountry Expected");
            }
            if (model.ShipAddress == null)
            {
                ModelState.AddModelError("ShipAddress", "ShipAddress Expected");
            }
            if (model.EmployeeID == 0)
            {
                ModelState.AddModelError("Employee", "EmployeeID Expected");
            }

            model.OrderDate = DateTime.UtcNow;

            if (!ModelState.IsValid)
            {
                ViewBag.Title = "Create New Order";
                return(View(model));
            }
            else
            {
                int orderID = CatalogBLL.AddOrder(model);
                return(RedirectToAction("Input", new { id = orderID }));
            }
        }