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)); } }
public void AddUserToProject(ProjectUserReq user) { if (user.Project is null) { user.Project = this; } if (!ProjectUsersReq.Contains(user)) { ProjectUsersReq.Add(user); } }
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}"); }