public TelephoneEditModel(Telephone _telephone)
 {
     this.TelephoneId = _telephone.TelephoneId;
     this.EquipmentName = _telephone.EquipmentName;
     this.SerialNumber = _telephone.SerialNumber;
     this.PurchasePrice = _telephone.PurchasePrice;
     this.Discarded = _telephone.Discarded;
     this.LostOrStolen = _telephone.LostOrStolen;
     this.isCheckedOut = _telephone.isCheckedOut;
     this.ApplicationUserId = _telephone.ApplicationUser.Id;
     this.Checkouts = _telephone.Checkouts == null ? new List<CheckoutViewModel>() { } : _telephone.Checkouts
         .Select(x => new CheckoutViewModel
         {
             dtCheckedOut = x.dtCheckedOut,
             dtReturned = x.dtReturned,
             Username = x.ApplicationUser.FirstName + " " + x.ApplicationUser.LastName
         })
         .ToList();
     if (_telephone.Sale != null)
     {
         this.dtSold = _telephone.Sale.dtSold;
         this.SalePrice = _telephone.Sale.SalePrice;
     }
 }
        public ActionResult Create(EquipmentCreateModel model)
        {
            if (ModelState.IsValid)
            {
                Telephone _telephone = new Telephone
                {
                    ApplicationUser = um.FindById(model.ApplicationUserId),
                    EquipmentName = model.EquipmentName,
                    SerialNumber = model.SerialNumber,
                    PurchasePrice = model.PurchasePrice,
                    isCheckedOut = false
                };
                db.Telephones.Add(_telephone);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            // Validation failed, reassign the list without assigning anything
            string selectId = model.ApplicationUserId;
            model.Users = FullNameUserList(db, selectId);

            return View(model);
        }