Beispiel #1
0
        public void GiveItemToUser(User_Item userItem)
        {
            Item item = Item.SingleOrDefault(t => t.ItemId == userItem.ItemId);
            item.IsOut = true;
            item.UserId = userItem.UserId;
            Entry(item).State = EntityState.Modified;
            SaveChanges();

            User_Item.Add(userItem);
            SaveChanges();
        }
        public ActionResult Create(User_Item user_item)
        {
            if (ModelState.IsValid)
            {
                user_item.Id = Guid.NewGuid();
                db.User_Item.Add(user_item);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.ItemId = new SelectList(db.Item, "ItemId", "Name", user_item.ItemId);
            ViewBag.UserId = new SelectList(db.User, "UserId", "Name", user_item.UserId);
            ViewBag.ParentUserItemId = new SelectList(db.User_Item, "Id", "Id", user_item.ParentUserItemId);
            return View(user_item);
        }
 public ActionResult Edit(User_Item user_item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user_item).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.ItemId = new SelectList(db.Item, "ItemId", "Name", user_item.ItemId);
     ViewBag.UserId = new SelectList(db.User, "UserId", "Name", user_item.UserId);
     ViewBag.ParentUserItemId = new SelectList(db.User_Item, "Id", "Id", user_item.ParentUserItemId);
     return View(user_item);
 }