예제 #1
0
 public static ProjectDto Map(Domain.Project model)
 {
     return(new ProjectDto
     {
         Id = model.Id,
         Name = model.Name
     });
 }
예제 #2
0
        public List <Domain.Task> GetProjectTasks(Domain.Project project)
        {
            var tasks = new List <Domain.Task>();

            GetChild(tasks, new List <Domain.Project> {
                project
            });
            return(tasks);
        }
예제 #3
0
 public static ProjectDto ToDto(this Domain.Project prj)
 {
     return(new ProjectDto
     {
         Id = prj.Id,
         Name = prj.Name,
         Tasks = prj.Tasks == null
   ? new List <TaskDto>()
   : prj.Tasks.Select(t => t.ToDto()).ToList()
     });
 }
예제 #4
0
        public async Task <long> Create(ProjectViewModel model)
        {
            var newId = await GetNextId();

            var project = new Domain.Project(newId, model.Name);
            await _context.Projects.AddAsync(project);

            await _context.SaveChangesAsync();

            return(newId);
        }
        public static ProjectIndexViewModel CreateNewViewModel(Domain.Project project)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            try
            {
                return(new ProjectIndexViewModel()
                {
                    Id = project.Id == null ? throw new ArgumentNullException() : project.Id,
                    Name = string.IsNullOrWhiteSpace(project.Name) ? throw new ArgumentNullException() : project.Name,
                    UsersCount = project.Users?.Count ?? 0,
                    TicketCount = project.Tickets?.Count ?? 0,
                    DateCreated = project.DateCreated == null ? throw new ArgumentNullException() : project.DateCreated,
                    DateUpdated = project.DateUpdated,
                });
            }
예제 #6
0
        public async Task <ProjectDto> Handle(NewProjectCommand request, CancellationToken cancellationToken)
        {
            var newProject = new LtmProject
            {
                ProjectName = request.ProjectName
            };

            //TO DO - Move to Repository.
            _projectRepository.Add(newProject);
            _ltmContext.Save();

            //TO DO - Use AutoMapper.
            var projectDto = new ProjectDto
            {
                Id          = newProject.Id,
                ProjectName = newProject.ProjectName
            };

            return(projectDto);
        }
        public static ProjectEditViewModel CreateNewViewModel(Domain.Project project, UserRepository userRepository)
        {
            if (project == null || userRepository == null)
            {
                throw new ArgumentNullException();
            }

            try
            {
                List <SelectListItem> usersRemove = new List <SelectListItem>();
                List <SelectListItem> usersAdd    = new List <SelectListItem>();

                SelectListGroup userAddGroup = new SelectListGroup()
                {
                    Name     = "Users To Add",
                    Disabled = false,
                };
                SelectListGroup userRemoveGroup = new SelectListGroup()
                {
                    Name     = "Users To Remove",
                    Disabled = false,
                };

                foreach (ApplicationUser user in userRepository.GetAllUsers().ToList())
                {
                    if (project.Users.Contains(user))
                    {
                        usersRemove.Add(new SelectListItem()
                        {
                            Text     = user.DisplayName,
                            Value    = user.Id,
                            Group    = userRemoveGroup,
                            Selected = false,
                            Disabled = false
                        });
                    }
                    else
                    {
                        usersAdd.Add(new SelectListItem()
                        {
                            Text     = user.DisplayName,
                            Value    = user.Id,
                            Group    = userAddGroup,
                            Selected = false,
                            Disabled = false
                        });
                    }
                }

                ProjectEditViewModel model = new ProjectEditViewModel()
                {
                    Id                    = project.Id,
                    Name                  = project.Name,
                    UsersAddList          = usersAdd,
                    UsersRemoveList       = usersRemove,
                    SelectedUsersToAdd    = null,
                    SelectedUsersToRemove = null,
                };

                return(model);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
예제 #8
0
 public async Task OnGetAsync(int id)
 {
     Project = await projectService.FindByIdAsync(id).ConfigureAwait(false);
 }
예제 #9
0
        public Enums.ProjectState GetProjectState(Domain.Project project)
        {
            var tasks = GetProjectTasks(project);

            return(GetProjectState(tasks));
        }
 public ProjectDashBoardViewModel(INavigationService viewNavigationService, Domain.Project project)
     : base(viewNavigationService)
 {
     this.project = project;
     this.Title = project.Name;
 }
        public ProjectModule(IAggregateRootRepository repository,
                             IIdGenerator idGenerator)
            :base("/write/project")
        {
            this.RequiresAuthentication();

            Post["/create"] = parameters =>
            {
                var model = this.Bind<EditableProject>();

                var client = repository.GetById<Domain.Client>(model.ClientId);
                var project = new Domain.Project(idGenerator.NextGuid(), model.Name, model.Description, client);

                repository.Save(project);

                return Json(new
                {
                    Project = new Project(client, project)
                });
            };

            Post["/update/{id:guid}"] = parameters =>
            {
                var model = this.Bind<EditableProject>();

                var project = repository.GetById<Domain.Project>((Guid)parameters.id);

                if (project != null)
                {
                    project.ChangeDetails(model.Name, model.Description);

                    if (model.Hidden)
                        project.Hide();
                    else project.Unhide();

                    repository.Save(project);

                    var client = repository.GetById<Domain.Client>(project.ClientId);

                    return Json(new
                    {
                        Project = new Project(client, project)
                    });
                }

                return null;
            };

            Post["/updatetasks/{id:guid}"] = parameters =>
            {
                var model = this.Bind<EditableProjectTasks>();

                var project = repository.GetById<Domain.Project>((Guid)parameters.id);

                if (project != null)
                {
                    project.ChangeTasks(model.Tasks.Select(t => new Domain.ValueObjects.Task { Name = t.Name, Rate = t.Rate }).ToArray());

                    repository.Save(project);

                    var client = repository.GetById<Domain.Client>(project.ClientId);

                    return Json(new
                    {
                        Project = new Project(client, project)
                    });
                }

                return null;
            };
        }
        public static ProjectDetailsViewModel CreateNewViewModel(string currentUserId, Domain.Project project, ApplicationDbContext dbContext)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            try
            {
                return(new ProjectDetailsViewModel()
                {
                    Id = project.Id == null ? throw new ArgumentNullException() : project.Id,
                    Name = string.IsNullOrWhiteSpace(project.Name) ? throw new ArgumentNullException() : project.Name,
                    Users = project.Users?.Select(user => HelperUserViewModel.CreateNewViewModel(user, dbContext)).ToList() ?? throw new ArgumentNullException(),
                    TicketCount = project.Tickets?.Count ?? 0,
                    Tickets = project.Tickets?.Select(ticket => TicketIndexViewModel.CreateNewViewModel(currentUserId, ticket)).ToList() ?? new List <TicketIndexViewModel>(),
                    DateCreated = project.DateCreated == null ? throw new ArgumentNullException() : project.DateCreated,
                    DateUpdated = project.DateUpdated,
                    CurrentUserId = currentUserId,
                });
            }