Пример #1
0
        // GET: Orders/Create
        public ActionResult Create()
        {
            var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();

            ViewBag.CustomerId = new SelectList(CombosHelpers.GetCustomers(user.CompanyID), "CustomerId", "FullName");
            var view = new NewOrderView
            {
                Date    = DateTime.Now,
                Details = db.OrderDetailTmps.Where(odt => odt.UserName == User.Identity.Name).ToList(),
            };

            return(View(view));
        }
Пример #2
0
        public ActionResult Create(Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();

            ViewBag.CustomerId = new SelectList(CombosHelpers.GetCustomers(user.CompanyId), "CustomerId", "FullName");

            return(View(order));
        }
Пример #3
0
        public ActionResult Create(NewOrderView view)
        {
            if (ModelState.IsValid)
            {
                var response = MovementsHelper.NewOrder(view, User.Identity.Name);
                if (response.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }
                ModelState.AddModelError(string.Empty, response.Message);
            }

            var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();

            ViewBag.CustomerId = new SelectList(CombosHelpers.GetCustomers(user.CompanyID), "CustomerId", "FullName");
            view.Details       = db.OrderDetailTmps.Where(odt => odt.UserName == User.Identity.Name).ToList();
            return(View(view));
        }