示例#1
0
        private ProjectDTO Create(ProjectViewModel viewModel)
        {
            try
            {
                log.Debug(ProjectViewModel.FormatProjectViewModel(viewModel));

                ProjectDTO project = new ProjectDTO();

                // copy values
                viewModel.UpdateDTO(project, null); //RequestContext.Principal.Identity.GetUserId());

                // audit
                project.CreateBy = null; //RequestContext.Principal.Identity.GetUserId();
                project.CreateOn = DateTime.UtcNow;

                // add
                log.Debug("_projectService.AddProject - " + ProjectDTO.FormatProjectDTO(project));

                int id = _projectService.AddProject(project);

                project.ProjectId = id;

                log.Debug("result: 'success', id: " + id);

                return(project);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
示例#2
0
        private void SubmitBug()
        {
            if (string.IsNullOrEmpty(textBoxBugName.Text.Trim()))
            {
                MessageBox.Show(@"Bug Name should not be empty.");
                return;
            }

            ProjectDTO project = null;

            if (comboBoxProject.SelectedItem != null)
            {
                project = GetByName(projects, comboBoxProject.SelectedItemText);
            }

            if (project == null)
            {
                MessageBox.Show(@"Please select a project to add the bug.");
                return;
            }


            FormBug(project);

            Cursor = Cursors.WaitCursor;
            buttonSubmit.Enabled = false;
            PostBug();
        }
示例#3
0
        private void CreateButton_Click(object sender, EventArgs e)
        {
            int index;

            using (var form = new AddForm())
            {
                var result = form.ShowDialog();
                if (result == DialogResult.OK)
                {
                    dataGridView1.Rows.Add();
                    index = dataGridView1.Rows.Count - 1;
                    dataGridView1[0, index].Value = form.ReturnValue1;
                    dataGridView1[1, index].Value = form.ReturnValue2;
                    dataGridView1[2, index].Value = form.ReturnValue3;
                    dataGridView1[3, index].Value = form.ReturnValue4;
                    dataGridView1[4, index].Value = form.ReturnValue5;
                    dataGridView1[5, index].Value = form.ReturnValue6;
                }
                else
                {
                    return;
                }
            }
            index = dataGridView1.Rows.Count - 1;
            ProjectDTO project = new ProjectDTO(
                Convert.ToInt32(dataGridView1[0, index].Value),
                dataGridView1[1, index].Value.ToString(),
                Convert.ToInt32(dataGridView1[2, index].Value),
                dataGridView1[3, index].Value.ToString(),
                Convert.ToDateTime(dataGridView1[4, index].Value),
                Convert.ToDateTime(dataGridView1[5, index].Value));

            ps.CreateProject(project);
        }
示例#4
0
        public ActionResult <ProjectDTO> Put([FromBody] ProjectDTO dto, long projectId)
        {
            try
            {
                var p = _projects.GetById(projectId);

                p.ProjectName   = dto.ProjectName;
                p.ProjectDescr  = dto.ProjectDescr;
                p.ProjectImage  = dto.ProjectImage;
                p.ProjectBudget = dto.ProjectBudget;
                p.ESchoolGrade  = dto.ESchoolYear;

                p.ClassRoomId         = dto.ClassRoomId;
                p.ApplicationDomainId = dto.ApplicationDomainId;

                p.UpdateProducts(dto.Products);
                p.UpdateGroups(dto.Groups, p.ClassRoom.SchoolId);
                p.UpdateEvaluationC(dto.EvaluationCritereas);


                _projects.SaveChanges();

                return(new ProjectDTO(p));
            }
            catch (ArgumentNullException)
            {
                return(NotFound(new CustomErrorDTO("Project niet gevonden")));
            }
        }
        public static Project DTOToProject(ProjectDTO projectDTO)
        {
            DateTime?inputStartDate = projectDTO.StartDate;

            if (projectDTO.StartDate.HasValue)
            {
                inputStartDate = projectDTO.StartDate.GetValueOrDefault();
            }
            DateTime?inputEndDate = projectDTO.EndDate;

            if (projectDTO.EndDate.HasValue)
            {
                inputEndDate = projectDTO.EndDate.GetValueOrDefault();
            }
            return(new Project
            {
                ResumeId = projectDTO.ResumeId,
                Order = projectDTO.Order,
                Name = projectDTO.Name,
                Description = projectDTO.Description,
                StartDate = inputStartDate,
                EndDate = inputEndDate,
                Resume = null
            });
        }
示例#6
0
        public async ValueTask <IActionResult> Report(int id)
        {
            //Get project of interest
            Project model = await _repo.Item()
                            .Where(x => x.Id == id)
                            .Include(x => x.Category)
                            .ThenInclude(c => c.Checks)
                            .Include(x => x.Sponsor)
                            .Include(x => x.Contractor)
                            .Include(x => x.Comments)
                            .ThenInclude(c => c.User)
                            .Include(x => x.Comments)
                            .ThenInclude(c => c.SubComments)
                            .ThenInclude(c => c.User)
                            .Include(x => x.Comments)
                            .ThenInclude(c => c.MyChecks)
                            .FirstOrDefaultAsync();

            if (model != null)
            {
                ProjectDTO project = model.ConvertToDTO(_mapper);
                return(Ok(new ReportDTO {
                    Report = GenerateReport(project)
                }));
            }

            return(NotFound(new ErrorDTO {
                Message = "project not found"
            }));
        }
示例#7
0
        public async ValueTask <IActionResult> Get(int id, bool view = false)
        {
            //Get project of interest
            Project model = await _repo.Item()
                            .Where(x => x.Id == id)
                            .Include(x => x.Category)
                            .ThenInclude(c => c.Checks)
                            .Include(x => x.Sponsor)
                            .Include(x => x.Contractor)
                            .Include(x => x.Comments)
                            .ThenInclude(c => c.User)
                            .Include(x => x.Comments)
                            .ThenInclude(c => c.SubComments)
                            .ThenInclude(c => c.User)
                            .Include(x => x.Comments)
                            .ThenInclude(c => c.MyChecks)
                            .FirstOrDefaultAsync();

            if (model != null)
            {
                if (view)
                {
                    await IncreaseProjectViews(model);
                }
                ProjectDTO project = model.ConvertToDTO(_mapper);

                return(Ok(project));
            }

            return(NotFound(new ErrorDTO {
                Message = "project not found"
            }));
        }
示例#8
0
        public async Task <IActionResult> AddProject(IFormFile formFile)
        {
            Request.Form.TryGetValue("project", out StringValues res);
            ProjectDTO project = JsonConvert.DeserializeObject <ProjectDTO>(res);

            if (Request.Form.Files.Count != 0)
            {
                IFormFile file = Request.Form.Files[0];
                byte[]    byteArr;
                using (var ms = new MemoryStream())
                {
                    file.CopyTo(ms);
                    await file.CopyToAsync(ms);

                    byteArr = ms.ToArray();
                }

                project.ImageUrl = await fileStorageProvider.UploadFileAsync(byteArr, FileType.Photo, Path.GetExtension(file.FileName));
            }

            var langIds = project.ProjectLanguageses.Select(l => l.Id);
            var entity  = await service.PostAsync(project);

            entity = await service.AddLanguagesToProject(entity.Id, langIds.ToArray());

            return(entity == null?StatusCode(409) as IActionResult
                   : Created($"{Request?.Scheme}://{Request?.Host}{Request?.Path}{entity.Id}",
                             entity));
        }
示例#9
0
        public async Task <IActionResult> ModifyProject(int id, IFormFile formFile)
        {
            Request.Form.TryGetValue("project", out StringValues res);

            ProjectDTO project = JsonConvert.DeserializeObject <ProjectDTO>(res);

            project.Id = id;

            if (Request.Form.Files.Count != 0)
            {
                IFormFile file = Request.Form.Files[0];
                byte[]    byteArr;
                using (var ms = new MemoryStream())
                {
                    file.CopyTo(ms);
                    await file.CopyToAsync(ms);

                    byteArr = ms.ToArray();
                }

                project.ImageUrl = await fileStorageProvider.UploadFileAsync(byteArr, FileType.Photo, Path.GetExtension(file.FileName));
            }

            var entity = await service.PutAsync(project);

            return(entity == null?StatusCode(304) as IActionResult
                   : Ok(entity));
        }
示例#10
0
        internal static Project ToEntity(ProjectDTO objet, bool creation)
        {
            Project retour = new Project();

            if (objet != null)
            {
                retour.Label          = objet.Label;
                retour.ProductOwnerId = objet.ProductOwnerId;
                retour.TeamId         = objet.TeamId;
                retour.ScrumMasterId  = objet.ScrumMasterId;
                retour.DepartmentId   = objet.DepartmentId;

                if (creation)
                {
                    retour.DateCreation     = DateTime.UtcNow;
                    retour.DateModification = DateTime.UtcNow;
                    retour.IsDeleted        = false;
                }
                else
                {
                    retour.Id               = objet.Id;
                    retour.DateCreation     = objet.DateCreation;
                    retour.DateModification = DateTime.UtcNow;
                    retour.IsDeleted        = objet.IsDeleted;
                }
            }
            return(retour);
        }
示例#11
0
        public async Task <IActionResult> Put(int projectId, [FromBody] ProjectDTO project)
        {
            var userId = await _userLogic.GetIdFromAzureUIdAsync(GetUserId());

            if (projectId != project.Id)
            {
                ModelState.AddModelError("Id", "Requesting routeId must match projectId");
            }
            if (project.Creator is null || project.Creator.Id != userId)
            {
                ModelState.AddModelError("Creator", "Updating userId must match requesting userId");
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var success = await _logic.UpdateAsync(project, userId);

            if (success == ResponseLogic.SUCCESS)
            {
                return(Ok());
            }
            else if (success == ResponseLogic.NOT_FOUND)
            {
                return(NotFound());
            }
            else
            {
                return(StatusCode(500));
            }
        }
示例#12
0
        public bool SaveProject(ProjectDTO projectDTO)
        {
            using (var unitOfWork = new UnitOfWork(new ApplicationDbContext()))
            {
                var projectInDB = unitOfWork.Projects.Get(projectDTO.ProjectId);

                if (projectInDB == null)
                {
                    projectInDB = Mapper.Map <Project>(projectDTO);
                    unitOfWork.Projects.Add(projectInDB);
                }
                else
                {
                    Mapper.Map(projectDTO, projectInDB);
                }

                try
                {
                    return(unitOfWork.Complete() > 0);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
        ProjectDTO IProjectsService.UpdateProject(ProjectDTO newProject)
        {
            Project updatedProject = _unitOfWork.Projects.Update(_mapper.Map <Project>(newProject));

            _unitOfWork.Save();
            return(_mapper.Map <ProjectDTO>(updatedProject));
        }
示例#14
0
        public async Task <IActionResult> UpdateProject(long id, ProjectDTO projectDTO)
        {
            if (id != projectDTO.Id)
            {
                return(BadRequest());
            }

            var project = await _context.Projects.FindAsync(id);

            if (project == null)
            {
                return(NotFound());
            }
            project.Name        = projectDTO.Name;
            project.Description = projectDTO.Description;
            project.IsComplete  = projectDTO.IsComplete;
            project.Url         = projectDTO.Url;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) when(!ProjectExists(id))
            {
                return(NotFound());
            }
            return(NoContent());
        }
示例#15
0
    void Start()
    {
        _sessionUser     = PlayerPrefs.GetString("SessionUserId");
        _project         = ProjectController.GetProject(PlayerPrefs.GetString("ProjectViewId"));
        _headerText      = GameObject.FindGameObjectWithTag("HeaderText").GetComponent <Text>();
        _headerText.text = "Обсуждение проекта" + Environment.NewLine + _project.Header;
        _messageField    = GameObject.FindGameObjectWithTag("MessageField").GetComponent <InputField>();
        _messagesList    = GameObject.FindGameObjectWithTag("MessagesList").GetComponent <Transform>();
        _messages        = MessageController.GetAllMessagesForProject(_project.Id);

        for (var i = 0; i < _messagesList.childCount; i++)
        {
            Destroy(_messagesList.GetChild(i).gameObject);
        }

        foreach (var message in _messages)
        {
            var temp   = Instantiate(MessagePrefab, _messagesList);
            var author = UserController.GetUserById(message.AuthorId);
            temp.transform.Find("Text").GetComponent <Text>().text   = message.Text;
            temp.transform.Find("Author").GetComponent <Text>().text = author.FirstName + " " + author.MiddleName + " " + author.LastName;
            temp.transform.Find("Date").GetComponent <Text>().text   = message.Date;
            if (_sessionUser == message.AuthorId)
            {
                temp.transform.Find("Edit").GetComponent <Button>().onClick.AddListener(() => OnEditButtonPressed(message.Id, message.Text));
                temp.transform.Find("Delete").GetComponent <Button>().onClick.AddListener(() => OnDeleteButtonPressed(message.Id));
            }
            else
            {
                temp.transform.Find("Edit").gameObject.SetActive(false);
                temp.transform.Find("Delete").gameObject.SetActive(false);
            }
        }
    }
        public void CreateScheduleTest()
        {
            ScheduleServise    scheduleServise    = new ScheduleServise(uow, new Map <Schedule, ScheduleDTO>(), new Map <ScheduleDay, ScheduleDayDTO>());
            EmployeeService    employeeService    = new EmployeeService(uow, new Map <Employee, EmployeeDTO>());
            ProjectService     projectService     = new ProjectService(uow, new Map <Project, ProjectDTO>());
            ProjectWorkService projectWorkService = new ProjectWorkService(uow, new Map <ProjectWork, ProjectWorkDTO>());

            EmployeeDTO employee = new EmployeeDTO
            {
                EmployeeName       = "Екатерина",
                EmployeeSurname    = "Антонович",
                EmployeePatronymic = "Алексеевна",
                RoleId             = 3,
                Email = "*****@*****.**",
            };
            var employeeOnWork = employeeService.CreateEmployee(employee);
            var em             = employeeService.GetEmployeeById(employeeOnWork.Id);

            ProjectDTO project = new ProjectDTO
            {
                ProjectName        = "проект 1",
                ProjectDescription = "проект номер один",
                ProjectStartDate   = new DateTimeOffset(2021, 10, 6, 10, 15, 35, new TimeSpan(3, 0, 0)),
                ProjectEndDate     = new DateTimeOffset(2021, 10, 21, 10, 15, 35, new TimeSpan(3, 0, 0))
            };
            var proj = projectService.CreateProject(project);
            var pr   = projectService.GetProjectById(proj.Id);

            ProjectWorkDTO projectWork = new ProjectWorkDTO
            {
                EmployeeId    = em.Id,
                ProjectId     = pr.Id,
                ProjectRoleId = 3
            };
            var pWork = projectWorkService.CreateProjectWork(projectWork);
            var prw   = projectWorkService.GetProjectWorkById(pWork.Id);

            ScheduleDTO schedule = new ScheduleDTO
            {
                ProjectWorkId = prw.Id,
                ScheduleDayId = 1
            };

            var         sch      = scheduleServise.CreateSchedule(schedule);
            ScheduleDTO actual   = scheduleServise.GetScheduleById(sch.Id);
            ScheduleDTO expected = new ScheduleDTO
            {
                Id            = actual.Id,
                ProjectWorkId = prw.Id,
                ScheduleDayId = 1
            };

            Assert.IsTrue(actual.Id == expected.Id && actual.ProjectWorkId == expected.ProjectWorkId &&
                          actual.ScheduleDayId == expected.ScheduleDayId);

            scheduleServise.DeleteScheduleById(actual.Id);
            projectWorkService.DeleteProjectWorkById(prw.Id);
            employeeService.DeleteEmployeeById(em.Id);
            projectService.DeleteProjectById(pr.Id);
        }
示例#17
0
        public void TestProjectMapping()
        {
            var project = new ProjectDTO()
            {
                SubProjects = new List <SubProjectDTO>()
                {
                    new ProjectDTO()
                    {
                        SubProjects = new List <SubProjectDTO>()
                        {
                            new SubProjectDTO()
                            {
                                Code = "123"
                            }
                        }
                    },
                    new ProjectDTO()
                    {
                        SubProjects = new List <SubProjectDTO>()
                    },
                    new SubProjectDTO()
                }
            };

            var mapped = Mapper.Map <Project>(project);

            Assert.All(mapped.SubProjects, x => Assert.Null(x.SubProjects)); // We do not want to have this mapped when using child class
        }
示例#18
0
 public int CreateProject(ProjectDTO project, int?userId)
 {
     return(Project.Create(
                project ?? throw new ArgumentNullException(nameof(project)),
                userId ?? throw new ArgumentNullException(nameof(userId))
                ));
 }
示例#19
0
        private string GenerateReport(ProjectDTO model)
        {
            StringBuilder reportGen = new StringBuilder(500);

            reportGen.Append($"This is a report on '{model.Title}'. ");
            string startVerb = model.StartDate >= DateTime.Now ? "supposedly started on" : "is expected to start on";
            string endVerb   = model.EndDate >= DateTime.Now ? "will supposedly finished on" : "is expected to end on";

            reportGen.Append($"The project {startVerb} {model.StartDate} and {endVerb} {model.EndDate}. ");
            reportGen.Append($"This is the brief: ");
            reportGen.Append($"{model.Brief} ");
            char plural = model.TotalComments > 1 ? 's' : ' ';

            reportGen.Append($"So far, this project has {model.TotalComments} direct comment{plural}. ");
            var _ = model.Comments.Select(c => {
                List <string> details = new List <string>();
                foreach (var item in model.Category.Checks)
                {
                    int totalSum = c.Checks.Count(check => check.Check.Id == item.Id);
                    if (totalSum != 0)
                    {
                        float percent = (float)totalSum / model.TotalComments;
                        reportGen.Append($"{percent}% of users claimed that {item.Name} is done. ");
                    }
                }
                return(true);
            });

            reportGen.Append($"Thank you.");
            return(reportGen.ToString());
        }
示例#20
0
        public IHttpActionResult Create([FromBody] ProjectDTO project)
        {
            ThrowIfUserHasNoRole(createRole);
            if (project == null)
            {
                throw new KairosException("Missing model parameter");
            }

            if (project.Project_PK != 0)
            {
                throw new KairosException("Post method is not allowed because the requested primary key is must be '0' (zero) .");
            }
            using (var projectCreateHandler = new ProjectCreateHandler(Db, ActiveUser, new ProjectValidator(), new ProjectFactory(Db, ActiveUser), new ProjectQuery(Db), AccessControl))
            {
                using (var transaction = new TransactionScope())
                {
                    var saveResult = projectCreateHandler.Save(projectDTO: project, dateStamp: DateTime.Now);
                    transaction.Complete();
                    if (saveResult.Success)
                    {
                        return(Ok(new SuccessResponse(saveResult.Model, saveResult.Message)));
                    }
                    return(Ok(new ErrorResponse(ServiceStatusCode.ValidationError, saveResult.ValidationResult, saveResult.Message)));
                }
            }
        }
        /// <summary>
        /// Gets project model to be inserted in database.
        /// </summary>
        /// <param name="projectViewModel">Project entity view model.</param>
        /// <param name="userObjectId">Azure Active Directory Id of logged-in user.</param>
        /// <returns>Returns a project entity model.</returns>
        public Project MapForCreateModel(ProjectDTO projectViewModel, Guid userObjectId)
        {
            projectViewModel = projectViewModel ?? throw new ArgumentNullException(nameof(projectViewModel));

            return(new Project
            {
                BillableHours = projectViewModel.BillableHours,
                ClientName = projectViewModel.ClientName,
                EndDate = projectViewModel.EndDate,
                NonBillableHours = projectViewModel.NonBillableHours,
                StartDate = projectViewModel.StartDate,
                CreatedBy = userObjectId,
                CreatedOn = DateTime.UtcNow,
                Title = projectViewModel.Title,
                Members = projectViewModel.Members.IsNullOrEmpty() ? new List <Member>() :
                          projectViewModel.Members.Select(member => new Member
                {
                    IsBillable = member.IsBillable,
                    UserId = member.UserId,
                    IsRemoved = false,
                }).ToList(),
                Tasks = projectViewModel.Tasks.IsNullOrEmpty() ? new List <TaskEntity>() :
                        projectViewModel.Tasks.Select(task => new TaskEntity
                {
                    Title = task.Title,
                    IsRemoved = false,
                    StartDate = task.StartDate.Date,
                    EndDate = task.EndDate.Date,
                }).ToList(),
            });
        }
示例#22
0
        public async Task <ActionResult <IEnumerable <object> > > GetUsuariosProjecto(int id)
        {
            var config = new MapperConfiguration(cfg => {
                cfg.CreateMap <Proyecto, ProjectDTO>();
            });
            IMapper iMapper = config.CreateMapper();

            var usuariosProjecto = await _context.UsuariosProyectos.Where(b => b.IdUsuario == id).ToListAsync();

            if (usuariosProjecto == null)
            {
                return(NotFound());
            }

            List <ProjectDTO> Proyectos = new List <ProjectDTO>();


            foreach (UsuariosProjecto usProyecto in usuariosProjecto)
            {
                ProjectDTO projectDTO = new ProjectDTO();
                Proyecto   proyecto   = await _context.Proyectos.Where(b => b.IdProyecto == usProyecto.IdProjecto).FirstOrDefaultAsync();

                projectDTO = iMapper.Map <Proyecto, ProjectDTO>(proyecto);

                Proyectos.Add(projectDTO);
                projectDTO = null;
            }


            return(Proyectos);
        }
示例#23
0
        public void MapFromDatabaseEntity_ValidProject_ReturnValidProjectDTO()
        {
            //Arrange
            var project = new Project
            {
                Id = new Guid("b58b6a58-2064-4c71-9b3d-c8c4514159a9"),
                ProjectInformation = new ProjectInformation(),
                CapitalPlan        = new CapitalPlan(),
                //Estimate = new Estimate(),
                RequisitionHeaders = new List <RequisitionHeader>(),
                POHeaders          = new List <POHeader>(),
                InvoiceHeaders     = new List <InvoiceHeader>(),
                //ScheduleDate = new ScheduleDate(),
                //BudgetMovementLog = new BudgetMovementLog()
            };

            //Act
            var result = ProjectDTO.MapFromDatabaseEntity(project);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(project.Id, result.Id);
            Assert.IsNotNull(result.ProjectInformation);
            Assert.IsNotNull(result.CapitalPlan);
            //Assert.IsNotNull(result.Estimate);
            Assert.IsNotNull(result.RequisitionHeaders);
            Assert.IsNotNull(result.POHeaders);
            Assert.IsNotNull(result.InvoiceHeaders);
            //Assert.IsNotNull(result.ScheduleDate);
            //Assert.IsNotNull(result.BudgetMovementLog);
        }
示例#24
0
        public void CreateProject(ProjectDTO projectDto)
        {
            Project project = new Project(projectDto.Id, projectDto.Name, projectDto.ManagerId, projectDto.Description,
                                          projectDto.ProjectStart, projectDto.ProjectEnd);

            db.projects.Create(project);
        }
示例#25
0
        /// <summary>
        /// Creates a new project.
        /// </summary>
        /// <param name="projectDetails">The project details.</param>
        /// <param name="userObjectId">The user object Id of project creator.</param>
        /// <returns>Returns project details.</returns>
        public async Task <Project> CreateProjectAsync(ProjectDTO projectDetails, Guid userObjectId)
        {
            projectDetails = projectDetails ?? throw new ArgumentNullException(nameof(projectDetails), "Project details cannot be null.");

            var project = this.projectMapper.MapForCreateModel(projectDetails, userObjectId);

            using (var transaction = this.repositoryAccessors.Context.Database.BeginTransaction())
            {
                try
                {
                    project = this.repositoryAccessors.ProjectRepository.CreateProject(project);

                    if (await this.context.SaveChangesAsync() > 0)
                    {
                        transaction.Commit();
                        return(project);
                    }
                }
#pragma warning disable CA1031 // Catching general exception to roll-back transaction.
                catch
#pragma warning restore CA1031 // Catching general exception to roll-back transaction.
                {
                    transaction.Rollback();
                }
            }

            return(null);
        }
示例#26
0
        public async Task <IEnumerable <ProjectDTO> > Create(ProjectDTO projectDTO)
        {
            Project project = CreateByMapper.CreateProjectByMapper(projectDTO);
            await database.Projects.Create(project);

            await database.Save();

            IEnumerable <Project> projects = database.Projects.Find(p =>
                                                                    p.Name == project.Name &&
                                                                    p.Customer == project.Customer &&
                                                                    p.Priority == project.Priority &&
                                                                    p.Performer == project.Performer &&
                                                                    p.StartDate == project.StartDate &&
                                                                    p.FinishDate == project.FinishDate &&
                                                                    p.LeadId == project.LeadId
                                                                    );

            if (projects == null)
            {
                return(null);
            }
            IEnumerable <ProjectDTO> projectDTOs = CreateByMapper.CreateProjectDTOByMapper(projects);

            return(projectDTOs);
        }
示例#27
0
        private void FormBug(ProjectDTO project)
        {
            bugDTO = new BugDTO
            {
                Name        = textBoxBugName.Text,
                Description = textBoxBugDescription.Text.Replace("\r\n", "<br/>"),
                ProjectID   = project.ID
            };

            var severity = GetByName(severities, comboBoxSeverity.SelectedItemText);

            if (severity != null)
            {
                bugDTO.SeverityID = severity.ID;
            }

            var priority = GetByName(priorities, comboBoxPriority.SelectedItemText);

            if (priority != null)
            {
                bugDTO.PriorityID = priority.ID;
            }

            var story = GetByName(Stories, comboBoxUserStory.SelectedItemText);

            if (story != null)
            {
                bugDTO.UserStoryID = story.ID;
            }

            bugDTO.Effort = 0;
        }
示例#28
0
        public async Task <IActionResult> UpdateAsync(ProjectDTO model)
        {
            Response <string> response = new Response <string>();

            try
            {
                if (model == null)
                {
                    return(BadRequest());
                }

                response = await _ProjectApplication.UpdateAsync(model);

                if (response.IsSuccess)
                {
                    return(Ok(response));
                }
                else
                {
                    return(BadRequest(response));
                }
            }
            catch (Exception ex)
            {
                response.Data      = null;
                response.IsSuccess = false;
                response.Message   = ex.Message;

                return(BadRequest(response));
            }
        }
示例#29
0
        public IActionResult Post(ProjectDTO model)
        {
            Project item = new Project();

            model.UpdateFromModel(item);

            item.LastEdit = DateTime.Now;

            if (_projectRepo.NameExists(item.OwnerId, item.Name))
            {
                return(Conflict("A project with this name already exists for that owner"));
            }

            _projectRepo.Add(item);
            _projectRepo.SaveChanges();

            ProjectDTO dto = new ProjectDTO {
                Id            = item.Id,
                Name          = item.Name,
                TeamId        = item.TeamId,
                OwnerId       = item.OwnerId,
                LastEdit      = item.LastEdit,
                ContactPerson = item.ContactPerson
            };

            return(CreatedAtAction(nameof(GetAll), dto));
        }
        public async Task <GetMyProjectsResponse> Handle(GetMyProjectsRequest query, CancellationToken cancellationToken)
        {
            var result = new GetMyProjectsResponse();

            var projects = await _context.Projects
                           .Where(x => x.MemberUsername == query.MemberUsername)
                           .Include(a => a.Blockchain)
                           .Include(a => a.Contributors)
                           .ToListAsync(cancellationToken);

            foreach (var project in projects)
            {
                ProjectDTO projectDTO = new ProjectDTO
                {
                    ProjectID      = project.ProjectID,
                    MemberUsername = project.MemberUsername,
                    Name           = project.Name,
                    BlockchainID   = project.Blockchain.BlockchainID,
                    BlockchainName = project.Blockchain.Name
                };

                result.Projects.Add(projectDTO);
            }

            result.IsSuccessful = true;

            return(result);
        }