예제 #1
0
        public override void Validate()
        {
            var proj = new Project();

            if (string.IsNullOrEmpty(Name) || string.IsNullOrWhiteSpace(Name))
            {
                AddBrokenRule(BusinessRule.Make <Project, string>
                                  (proj => proj.Name, MagicStrings.Project.Error.Name));
            }

            if (Deadline == null)
            {
                AddBrokenRule(BusinessRule.Make <Project, DateTime>(proj => proj.Deadline,
                                                                    MagicStrings.Project.Error.Deadline));
            }

            if (Id == null)
            {
                AddBrokenRule(BusinessRule.Make <Project, Guid>(proj => proj.Id,
                                                                MagicStrings.Project.Error.Id));
            }

            if (ProjectUsersReq.Count > 0 && ProjectUsersReq
                .Where(pur => pur.Role.RoleName == MagicStrings.Roles.ProjectManager) == null)
            {
                AddBrokenRule(BusinessRule.Make <Project, ICollection <ProjectUserReq> >(proj => proj.ProjectUsersReq,
                                                                                         MagicStrings.Project.Error.UsersOnProject));
            }
        }
예제 #2
0
        public void AddUserToProject(ProjectUserReq user)
        {
            if (user.Project is null)
            {
                user.Project = this;
            }

            if (!ProjectUsersReq.Contains(user))
            {
                ProjectUsersReq.Add(user);
            }
        }
예제 #3
0
        public override string ToString()
        {
            var owner = ProjectUsersReq?.Where(x => x.Role?.RoleName == MagicStrings.Roles.ProjectManager)
                        .OrderBy(x => x.RequestSent)
                        .Select(x => x.UserAssigned)
                        .FirstOrDefault();

            return($"Project:" +
                   $" Id: {Id}," +
                   $" Name: {Name}," +
                   $" Description: {Description}," +
                   $" Deadline: {Deadline}," +
                   $" Closed: {Closed}," +
                   $" OwnerId: {owner.Id}," +
                   $" OwnerUserName: {owner.UserName}");
        }