Пример #1
0
        public static UserCollection InitializeUserCollection()
        {
            UserCollection usercollection = new UserCollection();
            AUser          AdminUser      = new AUser("guy", "library", true);
            AUser          CustomerUser   = new AUser("sela", "sela123", false);
            AUser          CustomerUser2  = new AUser("user", "Aa123456", false);

            usercollection.Users.Add(AdminUser);
            usercollection.Users.Add(CustomerUser);
            return(usercollection);
        }
        public async void UserBorrowItem(AbstractItem item, AUser user)
        {
            try
            {
                if (item.IsBorrowed)
                {
                    throw new InvalidOperationException("Item is already borrowed! try a different one.");
                }
                user.Borrowed.Add(item);
                item.IsBorrowed = true;
            }

            catch (InvalidOperationException)
            {
                await new MessageDialog("Item is already borrowed! try a different one.").ShowAsync();
            }
        }
        public async void UserReturnItem(AbstractItem item, AUser user)
        {
            try
            {
                if (!item.IsBorrowed)
                {
                    throw new InvalidOperationException("Item is already returned and in library!");
                }
                else
                {
                    user.Borrowed.Remove(item);
                    item.IsBorrowed = false;
                }
            }

            catch (InvalidOperationException)
            {
                await new MessageDialog("Item is already returned and in library!").ShowAsync();
            }
        }
Пример #4
0
        public AUser VerifyUser(string username, string password)
        {
            AUser loginUser = FindUser(username);

            return(loginUser);
        }
Пример #5
0
 public void AddUser(AUser user)
 {
     Users.Add(user);
 }