public static ICollection <string> RoomList(this AssetHubContext db)
        {
            var list = (from r in db.Rooms
                        select r.Name).ToList();

            return(list);
        }
        public static ICollection <string> UserPositionList(this AssetHubContext db)
        {
            var list = (from p in db.UserPositions
                        select p.Name).ToList();

            return(list);
        }
        public static IEnumerable <SelectListItem> AssetModelDropdown(this AssetHubContext db)
        {
            var assetModels = db.AssetModels.Select(
                m => new SelectListItem
            {
                Value = m.Id.ToString(),
                Text  = m.Name,
            });

            return(new SelectList(assetModels, "Value", "Text"));
        }
        public static IEnumerable <SelectListItem> UserPositionDropdown(this AssetHubContext db)
        {
            var rooms = db.UserPositions.Select(
                m => new SelectListItem
            {
                Value = m.Id.ToString(),
                Text  = m.Name,
            });

            return(new SelectList(rooms, "Value", "Text"));
        }
        public static UserPosition FindOrAddUserPosition(this AssetHubContext db, string name)
        {
            var position = (from p in db.UserPositions
                            where p.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)
                            select p).FirstOrDefault();

            if (position == null)
            {
                position = new UserPosition {
                    Name = name
                };
                db.UserPositions.Add(position);
                db.SaveChanges();
            }

            return(position);
        }
        public static Room FindOrAddRoom(this AssetHubContext db, string name)
        {
            var room = (from r in db.Rooms
                        where r.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)
                        select r).FirstOrDefault();

            if (room == null)
            {
                room = new Room {
                    Name = name
                };
                db.Rooms.Add(room);
                db.SaveChanges();
            }

            return(room);
        }