Beispiel #1
0
 public void Commit()
 {
     if (Lib != null)
     {
         throw new InvalidOperationException("must not commit a model already connected to the library.");
     }
     Lib         = new Lib.User(FirstName, LastName, DefaultLocation.Lib);
     DisplayName = Lib.DisplayName;
     AccountID   = Lib.AccountID;
 }
Beispiel #2
0
 // GET: User/Details/5
 public ActionResult Details(int id)
 {
     ViewBag.Orders = s_libHelper.Orders.Where(o => o.User.AccountID == id && o.Time != null).Select(o =>
     {
         Location l = new Location(o.Location);
         return(new Order(o, l, new User(o.User, new Location(o.User.DefaultLocation))));
     });
     ILib.IUser lU = s_libHelper.Users.First(u => u.AccountID == id);
     return(View(new User(lU, new Location(lU.DefaultLocation))));
 }
Beispiel #3
0
 public User(LibI.IUser lib, Location location)
 {
     Lib = lib;
     if (location.Lib.ID != Lib.DefaultLocation.ID)
     {
         throw new InvalidOperationException("location inconsistent between model and library.");
     }
     DefaultLocation   = location;
     DefaultLocationID = location.ID;
     AccountID         = lib.AccountID;
     FirstName         = lib.FirstName;
     LastName          = lib.LastName;
     DisplayName       = lib.DisplayName;
 }
Beispiel #4
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 }));
        }