public void SaveAccountChanges()
        {
            if (!String.IsNullOrWhiteSpace(this.ImageName))
            {
                facade.Update(this.newProfilePicture);
                Model.ProfilePicture = new ProfileImageLightModel {
                    Id            = this.newProfilePicture.Id,
                    Content       = this.newProfilePicture.Content,
                    PictureFormat = this.newProfilePicture.PictureFormat
                };
            }
            facade.Update(Model);

            UserLightModel lightModel = new UserLightModel
            {
                Email           = Model.Email,
                FirstName       = Model.FirstName,
                Id              = Model.Id,
                LastName        = Model.LastName,
                UserDescription = Model.UserDescription,
                ProfilePicture  = Model.ProfilePicture
            };

            mediator.Send(new AccountUpdatedMessage {
                UserLightModel = lightModel
            });
        }
 private void UserTagAdded(UserLightModel userLightModel)
 {
     if (!TaggedUsers.Contains(userLightModel))
     {
         TaggedUsers.Add(userLightModel);
     }
 }
 private void UserTagRemove(UserLightModel userLightModel)
 {
     if (TaggedUsers.Contains(userLightModel))
     {
         TaggedUsers.Remove(userLightModel);
     }
 }
Beispiel #4
0
 private void DeleteUserFromTeam(UserLightModel userLightModel)
 {
     facade.DeleteUserFromTeam(userLightModel, this.SelectedTeam);
     mediator.Send(new TeamMembersUpdatedMessage {
         UpdatedTeam = this.SelectedTeam
     });
 }
        public IEnumerable <MyRecentActivityModel> GetRecentUserActivity(UserLightModel user)
        {
            const int contributionViewedNumber = 5;
            var       detailUser = GetDetail(user) as UserModel;
            List <MyRecentActivityModel> myRecentActivity = new List <MyRecentActivityModel>();

            foreach (var contribution in detailUser.MyContributions.OrderByDescending(contribution => contribution.Date).Take(contributionViewedNumber))
            {
                TeamLightModel teamAssociatedWithContribution = new TeamLightModel();
                switch (contribution)
                {
                case PostLightModel post:
                    teamAssociatedWithContribution = findAssociatedTeam(post);
                    break;

                case CommentLightModel comment:
                    teamAssociatedWithContribution = findAssociatedTeam(findAssociatedPost(comment));
                    break;
                }
                myRecentActivity.Add(new MyRecentActivityModel
                {
                    PublicationTime = contribution.Date, Contribution = contribution,
                    Team            = teamAssociatedWithContribution
                });
            }
            return(myRecentActivity);
        }
        public IEnumerable <TeamLightModel> FindMyTeams(UserLightModel user)
        {
            var allMembership = this.userTeamMemberRepository.GetAll().ToList();
            var allTeams      = this.teamRepository.GetAll().ToList();

            return(findMyTeams(allMembership, allTeams, user));
        }
Beispiel #7
0
        private void UserDetailToggleVisibility(UserLightModel userLightModel)
        {
            mediator.Send(new UserDetailToggleVisibilityMessage {
                UserLightModel = userLightModel
            });

            userDetailVisible = !userDetailVisible;
            UserDetailOverviewSwitchButtonText = (userDetailVisible) ? "Show Overview" : "Edit Account";
        }
Beispiel #8
0
        public void UpdatePicture_ToExistingUser_PictureChanged()
        {
            ProfileImageModel imageToUserJames = new ProfileImageModel
            {
                Id            = 650,
                Content       = new byte[10],
                FileName      = "Profile James Picture",
                PictureFormat = SupportedFormatPicture.Jpg
            };

            imageToUserJames = FacadeSUT.Create(imageToUserJames) as ProfileImageModel;

            var lightPic = new ProfileImageLightModel
            {
                Id = imageToUserJames.Id
            };

            UserModel james = new UserModel
            {
                Id = 651,
                AdministratedTeams   = new List <TeamLightModel>(),
                ContributionUserTags = new List <ContributionUserTagModel>(),
                Email           = "*****@*****.**",
                FirstName       = "James",
                LastName        = "Smith",
                MyContributions = new List <ContributionLightModel>(),
                Password        = "******",
                ProfilePicture  = lightPic,
                UserDescription = "James school account",
                UserTeams       = new List <UserTeamMemberModel>()
            };

            james = FacadeSUT.Create(james) as UserModel;

            var lightJames = new UserLightModel
            {
                Id = james.Id
            };

            var user = FacadeSUT.GetDetail(lightJames) as UserModel;

            //Act
            var newPicture = new ProfileImageLightModel
            {
                Id            = 650,
                Content       = new byte[20],
                PictureFormat = SupportedFormatPicture.Jpg
            };

            user.ProfilePicture = newPicture;
            FacadeSUT.Update(user.ProfilePicture);

            //Assert
            var returnedUser = FacadeSUT.GetDetail(user) as UserModel;

            Assert.Equal(newPicture.Content.ToString(), returnedUser.ProfilePicture.Content.ToString());
        }
        public void DeleteUserFromTeam(UserLightModel user, TeamLightModel team)
        {
            var unWantedUser = new UserTeamMemberModel
            {
                Team   = team,
                TeamId = team.Id,
                User   = user,
                UserId = user.Id
            };

            this.userTeamMemberRepository.Remove(unWantedUser.UserId, unWantedUser.TeamId);
        }
        public void JoinUserToTeam(UserLightModel user, TeamLightModel team)
        {
            var requestingUser = new UserTeamMemberModel
            {
                Team   = team,
                TeamId = team.Id,
                User   = user,
                UserId = user.Id
            };

            this.userTeamMemberRepository.Add(requestingUser);
        }
Beispiel #11
0
 public CarOrderPostModel(OrderModel model)
 {
     OrderNumer    = model.OrderNumer;
     PostId        = model.PostId;
     UserId        = model.UserId;
     DtCreate      = model.DtCreate;
     UserComment   = model.UserComment;
     Car           = model.Car;
     Cost          = model.Cost;
     DateWork      = model.DateWork;
     User          = new UserLightModel();
     SelectedWorks = new List <WorksInfoDataModel>();
 }
        public IEnumerable <ContributionLightModel> Search(string pattern, UserLightModel user)
        {
            IEnumerable <TeamModel> userTeams = new List <TeamModel>();

            userTeams = convertLightModelsToFullModels(this.FindMyTeams(user)).Cast <TeamModel>();
            var results = new List <ContributionLightModel>();

            foreach (var team in userTeams)
            {
                results.Concat(this.Search(pattern, team));
            }
            return(results);
        }
 public IActionResult Delete(UserLightModel form)
 {
     try
     {
         var user = userRepo.GetById(form.Id);
         DomainValidation.When(user == null, "User not found.");
         SetMessage(Messenger.SoftExclude(userRepo.SoftExclude(user)), MsgType.Success);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         SetMessage(e.Message, MsgType.Error); return(RedirectToAction("Index"));
     }
 }
Beispiel #14
0
        public void SearchUser_NotExistingPattern()
        {
            //Arrange
            var user = new UserLightModel()
            {
                Id = 1
            };
            //Act
            var contributions         = FacadeSUT.Search("salary", user);
            var numberOfContributions = contributions.Count();

            //Assert
            Assert.Equal(0, numberOfContributions);
        }
        public IEnumerable <PostModel> FindNewestNPostsForUser(UserLightModel user, int n)
        {
            var myTeams = convertLightModelsToFullModels(this.FindMyTeams(user)).Cast <TeamModel>();
            var timeOfNewestCommentInPost = new List <Tuple <DateTime, PostLightModel> >();

            foreach (var team in myTeams)
            {
                foreach (var post in team.Posts)
                {
                    timeOfNewestCommentInPost.Add(findNewesetCommentTimeInPost(post));
                }
            }
            return(selectNewestNPost(timeOfNewestCommentInPost, n));
        }
Beispiel #16
0
        public void FindNewestNPostsForUser_NoExistingPosts_ReturnsEmpty()
        {
            //Arrange
            var user = new UserLightModel()
            {
                Id = 10
            };
            //Act
            var newestPosts        = FacadeSUT.FindNewestNPostsForUser(user, 2);
            var numberOfFoundPosts = newestPosts.Count();

            //Assert
            Assert.Equal(0, numberOfFoundPosts);
        }
        public void DelegateAdminPosition(UserLightModel user, TeamLightModel team)
        {
            var teamModel        = GetDetail(team) as TeamModel;
            var teamWithNewAdmin = new TeamModel
            {
                Admin       = user,
                Description = teamModel.Description,
                Id          = teamModel.Id,
                Members     = teamModel.Members,
                Name        = teamModel.Name,
                Posts       = teamModel.Posts
            };

            this.Update(teamWithNewAdmin);
        }
Beispiel #18
0
        public void DeleteUser_AddedUser_UserDeleted()
        {
            ProfileImageModel imageToUserJames = new ProfileImageModel
            {
                Id            = 605,
                Content       = new byte[10],
                FileName      = "Profile James Picture",
                PictureFormat = SupportedFormatPicture.Jpg
            };

            var lightPic = new ProfileImageLightModel
            {
                Id = 605
            };

            FacadeSUT.Create(imageToUserJames);

            UserModel james = new UserModel
            {
                Id = 606,
                AdministratedTeams   = new List <TeamLightModel>(),
                ContributionUserTags = new List <ContributionUserTagModel>(),
                Email           = "*****@*****.**",
                FirstName       = "James",
                LastName        = "Smith",
                MyContributions = new List <ContributionLightModel>(),
                Password        = "******",
                ProfilePicture  = lightPic,
                UserDescription = "James school account",
                UserTeams       = new List <UserTeamMemberModel>()
            };

            FacadeSUT.Create(james);

            //Arrange
            var lightUser = new UserLightModel
            {
                Id = 606
            };

            //Act
            FacadeSUT.Delete(lightUser);

            var returned = FacadeSUT.GetDetail(lightUser);

            //Assert
            Assert.Null(returned);
        }
Beispiel #19
0
        public User MapUserLightModelToUser(UserLightModel lightModel)
        {
            if (lightModel == null)
            {
                return(null);
            }

            return(new User
            {
                Id = lightModel.Id,
                FirstName = lightModel.FirstName,
                LastName = lightModel.LastName,
                Email = lightModel.Email,
                UserDescription = lightModel.UserDescription,
                Photo = MapProfileImageLightModelToProfileImage(lightModel.ProfilePicture)
            });
        }
Beispiel #20
0
 public OrderViewModel()
 {
     if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
     {
         ID   = 1;
         User = new UserLightModel {
             Nm = "Иванов Петр Иванович"
         };
         Car = new DISP_Car {
             CarModel = { CarNumber = "Demo2", Mark = "Audio", Model = "A5" }
         };
         DateWork    = DateTime.Now;
         IsChanged   = false;
         _filterText = "User";
     }
     _storage.Update();
 }
Beispiel #21
0
 private void Save()
 {
     if (Model.Id == null)
     {
         Model = facade.Create(Model) as TeamModel;
         var lightTeam = new TeamLightModel {
             Id = Model.Id
         };
         var lightUser = new UserLightModel {
             Id = Model.Admin.Id
         };
         facade.JoinUserToTeam(lightUser, lightTeam);
     }
     else
     {
         facade.Update(Model);
     }
 }
Beispiel #22
0
        internal void UpdateOrder(OrderViewModel model)
        {
            ID              = model.ID;
            PostID          = model.PostID;
            _car            = model.Car;
            _comment        = model.Comment;
            _dateWork       = model.DateWork;
            _isChanged      = model.IsChanged;
            _nh             = model.NH;
            InUse           = model.InUse;
            IsCanMoveToUse  = model.IsCanMoveToUse;
            _user           = model.User ?? new UserLightModel();
            VisableUserList = model.User == null;
            _filterText     = model.User != null ? _user.Nm : "";

            _selectedWorks.Clear();
            CanDeleted = model.CanDeleted;
            model.SelectedWorks.ToList().ForEach(o => _selectedWorks.Add(o));
        }
Beispiel #23
0
        public void DelegateAdminPosition_WithExistingTeamAndUser_AdminDelegated()
        {
            //Arrange
            var teamModel = new TeamLightModel()
            {
                Id = 1
            };
            var notAdmin = new UserLightModel()
            {
                Id = 3
            };

            //Act
            FacadeSUT.DelegateAdminPosition(notAdmin, teamModel);
            var updatedTeam = FacadeSUT.GetDetail(teamModel) as TeamModel;

            //Assert
            Debug.Assert(updatedTeam != null, nameof(updatedTeam) + " != null");
            Assert.Equal(notAdmin.Id, updatedTeam.Admin.Id);
        }
Beispiel #24
0
        public void CreateClient(object sender)
        {
            User.Nm = _filterText;
            var model = new CreateClientModel
            {
                User           = User,
                IDBody         = Body.id,
                IDEngineType   = EngineType.id,
                IDEngine       = EngineVolume.id,
                IDMark         = Mark.id,
                IDModel        = Model.id,
                IDTransmission = TransmissionType.id,
                Number         = CarNumber,
                VIN            = VIN,
                Date           = new DateDataModel(DateProduce),
                Mileage        = Distance
            };

            _handler.CreateClient(model);
            _selectedUser = User;
            OnPropertyChanged("EnableAddWork");
        }
Beispiel #25
0
        private void createAccount(object parameter)
        {
            hideWarnings();
            var hashedPasswords = getHashedPasswords(parameter).ToList();

            if (facade.AreUserDataValid(Model.FirstName, Model.LastName, Model.Email, hashedPasswords[0], hashedPasswords[1]))
            {
                this.Model.Password = hashedPasswords[0];
                var            newUser = facade.Create(Model) as UserModel;
                UserLightModel newUserLightModel;
                try
                {
                    newUserLightModel = new UserLightModel
                    {
                        Id        = newUser.Id,
                        FirstName = newUser.FirstName,
                        LastName  = newUser.LastName,
                        Email     = newUser.Email
                    };
                }
                catch (NullReferenceException)
                {
                    ErrorWarning = true;
                    return;
                }
                var message = new SuccessfullyRegisteredMessage()
                {
                    User = newUserLightModel
                };
                RegisterPageVisibility = false;
                mediator.Send(message);
            }
            else
            {
                sendWarning(hashedPasswords[0], hashedPasswords[1]);
            }
        }
Beispiel #26
0
 private void LoadUser(UserAuthenticatedMessage loggedUser)
 {
     Model = loggedUser.User;
 }
Beispiel #27
0
 public CarOrderPostModel()
 {
     SelectedWorks = new List <WorksInfoDataModel>();
     User          = new UserLightModel();
     Car           = new CarViewModel(null);
 }
Beispiel #28
0
        public void JoinUserToTeam_UserAndTeamExist_UserIsTeamMember()
        {
            ProfileImageModel imageToUserJames = new ProfileImageModel
            {
                Id            = 620,
                Content       = new byte[10],
                FileName      = "Profile James Picture",
                PictureFormat = SupportedFormatPicture.Jpg
            };

            var lightPic = new ProfileImageLightModel
            {
                Id = 620
            };

            imageToUserJames = FacadeSUT.Create(imageToUserJames) as ProfileImageModel;

            UserModel userModel = new UserModel
            {
                Id = 621,
                AdministratedTeams   = new List <TeamLightModel>(),
                ContributionUserTags = new List <ContributionUserTagModel>(),
                Email           = "*****@*****.**",
                FirstName       = "James",
                LastName        = "Smith",
                MyContributions = new List <ContributionLightModel>(),
                Password        = "******",
                ProfilePicture  = new ProfileImageLightModel
                {
                    Id = imageToUserJames.Id
                },
                UserDescription = "James school account",
                UserTeams       = new List <UserTeamMemberModel>()
            };

            userModel = FacadeSUT.Create(userModel) as UserModel;

            var userLight = new UserLightModel
            {
                Id = userModel.Id
            };

            var teamModel = new TeamModel
            {
                Id          = 622,
                Name        = "Team1",
                Description = "First team",
                Admin       = new UserLightModel(),
                Members     = new List <UserTeamMemberModel>(),
                Posts       = new List <PostLightModel>()
            };

            teamModel = FacadeSUT.Create(teamModel) as TeamModel;

            var teamLight = new TeamLightModel
            {
                Id = teamModel.Id
            };

            //Act
            FacadeSUT.JoinUserToTeam(userLight, teamLight);

            //Assert
            var teamsMembers = FacadeSUT.GetAllMembers(teamLight).ToList();

            Assert.Contains(teamsMembers, member => member.Id == userLight.Id);
            FacadeSUT.DeleteUserFromTeam(userLight, teamLight);
        }
Beispiel #29
0
        public void getAllPostsInIFJTeam_twoPosts_notThrow()
        {
            //Arrange
            var imageToUserLucas = new ProfileImageModel
            {
                Id            = 810,
                Content       = new byte[10],
                FileName      = "Profile Lucas Picture",
                PictureFormat = SupportedFormatPicture.Png
            };

            imageToUserLucas = FacadeSUT.Create(imageToUserLucas) as ProfileImageModel;

            var imageToUserLucasLight = new ProfileImageLightModel
            {
                Id = imageToUserLucas.Id
            };


            var lucas = new UserModel
            {
                Id = 811,
                AdministratedTeams   = new List <TeamLightModel>(),
                ContributionUserTags = new List <ContributionUserTagModel>(),
                Email           = "*****@*****.**",
                FirstName       = "Lucas",
                LastName        = "Collins",
                MyContributions = new List <ContributionLightModel>(),
                Password        = "******",
                ProfilePicture  = imageToUserLucasLight,
                UserDescription = "Lucas school account",
                UserTeams       = new List <UserTeamMemberModel>()
            };

            lucas = FacadeSUT.Create(lucas) as UserModel;

            var lucasLight = new UserLightModel
            {
                Id = lucas.Id
            };

            var teamIFJ = new TeamModel
            {
                Id          = 812,
                Admin       = lucasLight,
                Description = "Team for formal language and compilators (IFJ) project.",
                Name        = "IFJ team",
                Posts       = new List <PostLightModel>(),
                Members     = new List <UserTeamMemberModel>()
            };

            teamIFJ = FacadeSUT.Create(teamIFJ) as TeamModel;

            var teamLight = new TeamLightModel
            {
                Id = teamIFJ.Id
            };

            FacadeSUT.JoinUserToTeam(lucasLight, teamLight);

            var lucasPostInIFJ = new PostModel
            {
                Id = 813,
                AssociatedFiles      = new List <ContributionFileLightModel>(),
                Author               = lucasLight,
                Comments             = new List <CommentModel>(),
                Content              = "Download documentation on private web.",
                ContributionUserTags = new List <ContributionUserTagModel>(),
                CorrespondingTeam    = teamLight,
                Date  = new DateTime(2019, 2, 1),
                Title = "Project has been released!"
            };

            lucasPostInIFJ = FacadeSUT.Create(lucasPostInIFJ) as PostModel;

            teamIFJ = FacadeSUT.GetDetail(teamLight) as TeamModel;
            //Act
            var allPosts = FacadeSUT.GetAllPostsInTeam(teamIFJ).ToList();

            //Assert
            Assert.Contains(allPosts, model => model.Id == lucasPostInIFJ.Id);
        }
Beispiel #30
0
        public void findAllNonMemebrs_UserIsNotMember_UserIsInNonmembersList()
        {
            //Arrange
            ProfileImageModel imageToUserJames = new ProfileImageModel
            {
                Id            = 670,
                Content       = new byte[10],
                FileName      = "Profile James Picture",
                PictureFormat = SupportedFormatPicture.Jpg
            };

            var lightPic = new ProfileImageLightModel
            {
                Id = imageToUserJames.Id
            };

            imageToUserJames = FacadeSUT.Create(imageToUserJames) as ProfileImageModel;

            UserModel userModel = new UserModel
            {
                Id = 671,
                AdministratedTeams   = new List <TeamLightModel>(),
                ContributionUserTags = new List <ContributionUserTagModel>(),
                Email           = "*****@*****.**",
                FirstName       = "James",
                LastName        = "Smith",
                MyContributions = new List <ContributionLightModel>(),
                Password        = "******",
                ProfilePicture  = new ProfileImageLightModel
                {
                    Id = imageToUserJames.Id
                },
                UserDescription = "James school account",
                UserTeams       = new List <UserTeamMemberModel>()
            };

            userModel = FacadeSUT.Create(userModel) as UserModel;

            var userLight = new UserLightModel
            {
                Id = userModel.Id
            };

            var teamModel = new TeamModel
            {
                Id          = 672,
                Name        = "Team1",
                Description = "First team",
                Admin       = new UserLightModel(),
                Members     = new List <UserTeamMemberModel>(),
                Posts       = new List <PostLightModel>()
            };

            teamModel = FacadeSUT.Create(teamModel) as TeamModel;

            var teamLight = new TeamLightModel
            {
                Id = teamModel.Id
            };


            //Act
            var allNonUsers = FacadeSUT.GetAllNonMembers(teamLight);

            //Assert
            Assert.Contains(allNonUsers, model => model.Id == userModel.Id);
        }