コード例 #1
0
        public ActionResult Create(IFormCollection collection)
        {
            int      userID     = (int)TempData["UserID"];
            int      locationID = int.Parse(collection["LocationID"]);
            Location location   = new Location(s_libHelper.Locations.First(l => l.ID == locationID));

            LibI.IUser lU    = s_libHelper.Users.First(u => u.AccountID == userID);
            User       user  = new User(lU, new Location(lU.DefaultLocation));
            Order      order = new Order(location.Lib.SuggestOrder(lU), location, user);

            s_libHelper.Reload();
            var orderIDs = new List <int>(TempData["OrderIDs"] as int[] ?? new int[] { })
            {
                order.ID
            };

            TempData["OrderIDs"] = orderIDs.ToArray <int>();

            return(RedirectToAction(nameof(Index), new { id = userID }));
        }
コード例 #2
0
        public ActionResult Create(Location location)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    throw new ArgumentException("invalid location.");
                }
                location.Commit();
                s_libHelper.Reload();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(RedirectToAction(nameof(Create)));
            }
        }
コード例 #3
0
        public ActionResult Create(User user)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    throw new ArgumentException("invalid user.");
                }
                user.DefaultLocation = new Location(s_libHelper.Locations.First(l => l.ID == user.DefaultLocationID));
                user.Commit();
                s_libHelper.Reload();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(RedirectToAction(nameof(Create)));
            }
        }