Example #1
0
        public ActionResult Detail(int id)
        {
            ProjectHandler     handler = new ProjectHandler(new ProjectDataAccess());
            ProjectDetailModel model   = handler.GetProjectDetail(id);

            return(View(model));
        }
Example #2
0
        public void Can_GetById_Project()
        {
            //Arrange

            var mockRepository = new Mock <IProjectRepository>();

            mockRepository.Setup(m => m.GetById(It.IsAny <int>())).Returns(new Project
            {
                Id          = 1,
                Name        = "pierwszy",
                Information = new ClientInformation {
                    ContactData = "contactData1"
                },
                Status = ProjectStatus.Active
            });
            IGetProject service = new GetProject(mockRepository.Object);

            //Act

            ProjectDetailModel result = service.Invoke(1);

            //Assert

            Assert.True(result.Id == 1);
            Assert.True(result.Name == "pierwszy");
            Assert.True(result.ContactData == "contactData1");
        }
Example #3
0
        public async Task <IActionResult> ActivityTypes(ProjectDetailModel model)
        {
            var activeElements = model.ProjectActivityTypes.Where(x => x.Active).Select(x => x.ActivityTypeId).ToList();

            if (activeElements.Any())
            {
                if (await Mediator.Send(new ChangeProjectActivityTypeStatesCommand
                {
                    ProjectId = model.Id,
                    ActivityTypeIds = activeElements,
                    Active = true
                }) == null)
                {
                    return(BadRequest());
                }
            }

            var inactiveElements = model.ProjectActivityTypes.Where(x => !x.Active).Select(x => x.ActivityTypeId).ToList();

            if (inactiveElements.Any())
            {
                if (await Mediator.Send(new ChangeProjectActivityTypeStatesCommand
                {
                    ProjectId = model.Id,
                    ActivityTypeIds = inactiveElements,
                    Active = false
                }) == null)
                {
                    return(BadRequest());
                }
            }

            return(RedirectToAction("ActivityTypes", new { projectId = model.Id }));
        }
        public IHttpActionResult PostProject(ProjectDetailModel projectModal)
        {
            var project = new Project();
            var config  = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <ProjectDetailModel, Project>();
            });
            IMapper iMapper = config.CreateMapper();

            project = iMapper.Map <ProjectDetailModel, Project>(projectModal);
            db.Projects.Add(project);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                throw;
            }

            var user = db.Users.Find(projectModal.User_ID);

            user.Project_ID = project.Project_Id;
            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(CreatedAtRoute("DefaultApi", new { id = project.Project_Id }, project));
        }
Example #5
0
        //
        // GET: /Project/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var     issues  = db.Issues.Where(i => i.ProjectId == id).Include(i => i.Developer);
            Project project = db.Projects.Find(id);

            if (project == null)
            {
                return(HttpNotFound());
            }

            var model = new ProjectDetailModel
            {
                Id          = project.Id,
                Title       = project.Title,
                Description = project.Description,
                Customer    = project.Customer,
                ManagerName = db.Users.Find(project.ManagerId).UserName,
                Issues      = issues.ToList()
            };

            return(View(model));
        }
Example #6
0
        public async Task <IActionResult> Put(int id, [FromBody] ProjectDetailModel projectDetailModel)
        {
            try
            {
                if (projectDetailModel == null || projectDetailModel.ProjectId != id)
                {
                    _logger.LogInformation("Provide valid project item detail");
                    return(BadRequest("Invalid project detail"));
                }

                if (!_projectManager.IsProjectValid(projectDetailModel))
                {
                    return(BadRequest("This project has active tasks. Active tasks has to be closed before closing project"));
                }

                await _projectManager.UpdateProjectDetails(id, projectDetailModel);

                _logger.LogInformation($"Updated project with id  {projectDetailModel.ProjectId}");

                return(Ok($"{projectDetailModel.ProjectName} Saved"));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode((int)HttpStatusCode.InternalServerError, "An exception has occured with Service, Please contact service team"));
            }
        }
Example #7
0
        /// <summary>
        /// Get basic information about project
        /// </summary>
        /// <returns>Instance of ProjectDetailModel</returns>
        public Result <ProjectDetailModel> GetProjectDetail()
        {
            var data = new ProjectDetailModel
            {
                Id   = 1,
                Name = "E-commerce template"
            };

            return(Ok(data));
        }
Example #8
0
        public bool BuildProjectDetails(ProjectDetailModel projectDetailModel)
        {
            if (projectDetailModel == null)
            {
                return(false);
            }

            _projectDetailModel = projectDetailModel;
            return(true);
        }
        public IHttpActionResult PutProject(int id, ProjectDetailModel projectModal)
        {
            if (id != projectModal.Project_Id)
            {
                return(BadRequest());
            }

            var project = new Project();
            var config  = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <ProjectDetailModel, Project>();
            });
            IMapper iMapper = config.CreateMapper();

            project = iMapper.Map <ProjectDetailModel, Project>(projectModal);

            //db.Entry(project).State = EntityState.Modified;
            db.MarkAsModified(project);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }


            var changeUser = db.Users.Where(x => x.Project_ID == project.Project_Id).FirstOrDefault();

            changeUser.Project_ID = null;
            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            var user = db.Users.Find(projectModal.User_ID);

            user.Project_ID = project.Project_Id;
            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task VerifyProjectUpdateCalledOnce()
        {
            // Arrange
            var mockRepository = new Mock <IProjectDetailsRepository>();
            var userManger     = new ProjectManger(mockRepository.Object);
            var projectDetail  = new ProjectDetailModel();

            // Act
            await userManger.UpdateProjectDetails(10, projectDetail);

            // Assert
            mockRepository.Verify(t => t.Update(10, projectDetail), Times.Once);
        }
Example #11
0
        public IActionResult Detail(Guid id)
        {
            var project = _bug.GetProjectById(id);
            var model   = new ProjectDetailModel
            {
                AssignedTo  = _userBug.GetUserByProject(project).UserName,
                Description = project.Description,
                Email       = _userBug.GetUserByProject(project).Email,
                Name        = project.Name,
                Team        = project.Owner.Name
            };

            return(View(model));
        }
Example #12
0
        public IActionResult Detail(int id)
        {
            var project = _project.Get(id);

            var model = new ProjectDetailModel
            {
                ProjectName        = project.ProjectName,
                ProjectDescription = project.ProjectDescription,
                Pictures           = project.Pictures,
                ProjectGitHubLink  = project.ProjectGitHubLink,
                Tags = project.Tags
            };

            return(View(model));
        }
Example #13
0
        public ProjectDetailModel GetProjectDetail(int id)
        {
            ProjectDetailModel result        = new ProjectDetailModel();
            ProjectResult      projectResult = _projectDataAccess.FindProject(id);

            result.Subject           = projectResult.Subject;
            result.Status            = projectResult.Status;
            result.StartTime         = projectResult.StartTime.ToShortDateString();
            result.EndTime           = projectResult.EndTime.ToShortDateString();
            result.Description       = projectResult.Description;
            result.RecentSprint      = projectResult.RecentSprint;
            result.ReleasedVersion   = projectResult.ReleasedVersion;
            result.SourceRespository = projectResult.SourceRespository;

            return(result);
        }
Example #14
0
        public ActionResult PRCreate(ProjectDetailModel model)
        {
            Remind remind = new Remind()
            {
                ProjectId   = model.project.Id,
                Description = model.remind.Description,
                CreateTime  = DateTime.Now,
                Title       = model.remind.Title,
                WhoUser     = "******",
            };

            db.Reminds.Add(remind);
            db.SaveChanges();

            return(RedirectToAction("Detail", "Project", new { id = model.project.Id }));
        }
Example #15
0
        public static ProjectDetailModel MapProjectDetailModel(ProjectDto dto)
        {
            var model = new ProjectDetailModel();

            model.OrganizationUid  = dto.OrganizationUid;
            model.OrganizationName = dto.OrganizationName;

            model.ProjectUid          = dto.Uid;
            model.Name                = dto.Name;
            model.Description         = dto.Description;
            model.Url                 = dto.Url;
            model.LabelCount          = dto.LabelCount;
            model.IsActive            = dto.IsActive;
            model.IsActiveInput.Value = dto.IsActive;

            model.SetInputModelValues();
            return(model);
        }
Example #16
0
        public ActionResult ProjectDetail(int id)
        {
            ProjectDetailModel model = new ProjectDetailModel();
              using (DeneysanContext db = new DeneysanContext())
              {
               Projects project = db.Projects.Where(x => x.ProjeId == id).FirstOrDefault();
            if(project!=null)
            {
              model.Project = project;

              List<ProjectsGallery> gallery = db.ProjectsGallery.Where(x=>x.ProjeId==id).ToList();
              if(gallery!=null && gallery.Count()>0 )
            model.ProjectImages = gallery;
            }

            return View(model);
              }
        }
Example #17
0
        public async Task <IActionResult> Post([FromBody] ProjectDetailModel project)
        {
            try
            {
                if (project == null)
                {
                    _logger.LogInformation("Invalid project item detail.");
                    return(BadRequest());
                }

                await _projectManager.AddProjectDetails(project);

                _logger.LogInformation($"Inserted project to database with id {project.ProjectId}");

                return(Ok($"Project with id {project.ProjectId} created successfully"));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode((int)HttpStatusCode.InternalServerError, "An exception has occured with Service while inserting task, Please contact service team"));
            }
        }
Example #18
0
        public ActionResult Detail(int id)
        {
            Project            P   = db.Projects.Find(id);
            ProjectDetailModel PDM = new ProjectDetailModel()
            {
                project = new Project()
                {
                    Id                = P.Id,
                    CustomerId        = P.CustomerId,
                    CustomerUserName  = P.CustomerUserName,
                    Description       = P.Description,
                    Title             = P.Title,
                    StateName         = P.StateName,
                    Sorumluenumolacak = P.Sorumluenumolacak,
                    End               = P.End,
                    Start             = P.Start,
                    TimeControl       = P.TimeControl,
                },
                reminds = db.Reminds.Where(w => w.ProjectId == P.Id).ToList(),
            };

            return(View(PDM));
        }
Example #19
0
        public List <ProjectDetailModel> Get()
        {
            List <ProjectDetailModel> l_ProjectDetailModels = new List <ProjectDetailModel>();

            using (masterEntities mstEntities = new masterEntities())
            {
                List <int> l_ProjectIDs = new List <int>();

                l_ProjectIDs = mstEntities.Projects.Select(x => x.Project_ID).ToList();
                //l_ProjectIDs = l_project.Select(x => x.Project_ID).ToList();
                if (l_ProjectIDs?.Count > 0)
                {
                    foreach (var item in l_ProjectIDs)
                    {
                        Project l_p = new Project();
                        l_p = mstEntities.Projects.Where(t => t.Project_ID == item).Select(x => x).FirstOrDefault();

                        //ProjectModel l_p = new ProjectModel();
                        //l_p = l_project.Where(t => t.Project_ID == item).Select(x => x).FirstOrDefault();

                        ProjectDetailModel PD = new ProjectDetailModel();
                        PD.NoOfTask      = mstEntities.Tasks.Where(t => t.Project_ID == item).Count();
                        PD.PDEndDate     = l_p.EndDate;
                        PD.PDPriority    = Convert.ToInt32(l_p.Priority);
                        PD.PDProjectID   = l_p.Project_ID;
                        PD.PDProjectName = l_p.ProjectName;
                        PD.PDStartDate   = l_p.StartDate;
                        PD.UserID        = Convert.ToInt32(l_p.User_ID);
                        PD.TaskCompleted = mstEntities.Tasks.Where(t => t.Project_ID == item && t.Status == "Completed").Count();

                        l_ProjectDetailModels.Add(PD);
                    }
                }
            };

            return(l_ProjectDetailModels);
        }
Example #20
0
        public ProjectDetailModel GetProjectDetail(int id)
        {
            //throw new Exception();
            var identity = HttpContext.User.Identity as ClaimsIdentity;

            if (identity != null)
            {
                //validate if user can access to specific projct
                string email          = identity.FindFirst("UserEmail").Value;
                var    hasUserProject = context.UserProject.Where(u => u.ProjectId == id && u.UsersEmail == email).FirstOrDefault();
                if (hasUserProject != null)
                {
                    if (hasUserProject.UsersEmail == identity.FindFirst("UserEmail").Value)
                    {
                        ProjectDetailModel detailsModel = new ProjectDetailModel();
                        Project            project      = context.Project.Where(p => p.Id == id).FirstOrDefault();
                        ProjectModel       model        = new ProjectModel()
                        {
                            Id = project.Id, Description = project.Description, Name = project.Name, Owner = project.UsersEmail
                        };
                        detailsModel.ProjectModel = model;
                        Workproduct[]           workproducts = context.Workproduct.Where(p => p.ProjectId == id).ToArray();
                        List <WorkProductModel> wmodel       = new List <WorkProductModel>();
                        foreach (Workproduct w in workproducts)
                        {
                            wmodel.Add(new WorkProductModel()
                            {
                                Name = w.Name, Description = w.Description, Id = w.Id, ProjectId = w.ProjectId
                            });
                        }
                        detailsModel.WorkproductModel = wmodel.ToArray();
                        return(detailsModel);
                    }
                }
            }
            return(null);
        }
Example #21
0
        protected WorkHistoryDetailsModel PrepareWorkHistoryDetailsModel(Resume workHistory)
        {
            var model = new WorkHistoryDetailsModel()
            {
                Id = workHistory.Id,

                Name        = workHistory.Name,
                Address     = workHistory.Address,
                PostalCode  = workHistory.PostalCode,
                Town        = workHistory.Town,
                Phone       = workHistory.Phone,
                Mobile      = workHistory.Mobile,
                Email       = workHistory.Email,
                DateOfBirth = workHistory.DateOfBirth,
                Website     = workHistory.Website
            };
            var summary = workHistory.GetLocalized(x => x.Summary);

            if (!String.IsNullOrWhiteSpace(summary))
            {
                model.Summary = summary.Replace("\r\n", "<br />");
                model.Summary = model.Summary.Replace("\n", "<br />");
            }

            #region Education

            foreach (var education in workHistory.Educations)
            {
                var educationModel = new EducationDetailsModels()
                {
                    Id   = education.Id,
                    Name = education.GetLocalized(x => x.Name)
                };

                foreach (var educationItem in education.EducationItems)
                {
                    var educationItemModel = new EducationDetialItemModel()
                    {
                        Id   = educationItem.Id,
                        Name = educationItem.GetLocalized(x => x.Name),
                        //Descriptions = Regex.Split(educationItem.GetLocalized(x => x.Description), "\r\n").ToList(),
                        Period = educationItem.GetLocalized(x => x.Period),
                        Place  = educationItem.GetLocalized(x => x.Place)
                    };
                    var description = HtmlHelper.StripTags(educationItem.GetLocalized(x => x.Description));
                    description = description.Replace("-", "");

                    if (description != null && description.Contains("\r\n"))
                    {
                        educationItemModel.Descriptions = Regex.Split(description, "\r\n").ToList();
                        educationItemModel.Descriptions.RemoveAll(x => String.IsNullOrWhiteSpace(x));
                    }
                    else
                    {
                        educationItemModel.Descriptions.Add(description);
                    }

                    educationModel.EducationItems.Add(educationItemModel);
                }
                model.Educations.Add(educationModel);
            }

            #endregion

            #region Skill
            var skills = workHistory.Skills;
            foreach (var skill in skills.OrderBy(x => x.DisplayOrder))
            {
                var skillModel = new SkillDetailsModels()
                {
                    Id   = skill.Id,
                    Name = skill.GetLocalized(x => x.Name)
                };

                foreach (var skillItem in skill.SkillItems.OrderByDescending(x => x.Level))
                {
                    var skillItemModel = new SkillItemDetailModel()
                    {
                        Id               = skillItem.Id,
                        Level            = skillItem.Level * 10,
                        Name             = skillItem.GetLocalized(x => x.Name),
                        LevelDescription = skillItem.GetLocalized(x => x.LevelDescription)
                    };
                    skillModel.SkillItems.Add(skillItemModel);
                }
                model.Skills.Add(skillModel);
            }
            #endregion

            #region Experience

            foreach (var experience in workHistory.Experiences.OrderByDescending(x => x.DisplayOrder))
            {
                var experienceModel = new WorkExperienceDetailsModels()
                {
                    Id       = experience.Id,
                    Name     = experience.GetLocalized(x => x.Name),
                    Period   = experience.GetLocalized(x => x.Period),
                    Function = experience.GetLocalized(x => x.Function),
                    City     = experience.GetLocalized(x => x.City),
                    //Tasks = Regex.Split(experience.GetLocalized(x => x.Tasks), "\r\n")
                };
                var tasks = experience.GetLocalized(x => x.Tasks);
                experienceModel.Tasks = tasks.Replace("\r\n", "<br >");

                foreach (var project in experience.Projects)
                {
                    var projectModel = new ProjectDetailModel()
                    {
                        Id          = project.Id,
                        Name        = project.GetLocalized(x => x.Name),
                        Description = project.GetLocalized(x => x.Description),
                        Technology  = project.GetLocalized(x => x.Technology)
                    };
                    experienceModel.Projects.Add(projectModel);
                }
                model.Experiences.Add(experienceModel);
            }
            #endregion

            return(model);
        }
Example #22
0
        public async Task Update(int id, ProjectDetailModel entity)
        {
            _projectManagerDbContext.Projects.Update(entity);

            await _projectManagerDbContext.SaveChangesAsync();
        }
Example #23
0
 public async Task <int> Insert(ProjectDetailModel entity)
 {
     entity.UserDetail = null;
     _projectManagerDbContext.Projects.Add(entity);
     return(await _projectManagerDbContext.SaveChangesAsync());
 }
Example #24
0
        public async Task Delete(ProjectDetailModel entity)
        {
            _projectManagerDbContext.Projects.Remove(entity);

            await _projectManagerDbContext.SaveChangesAsync();
        }
Example #25
0
 public async Task <int> AddProjectDetails(ProjectDetailModel project)
 {
     return(await _projectDetailsRepository.Insert(project));
 }
Example #26
0
        public bool IsProjectValid(ProjectDetailModel project)
        {
            var isValid = !project.TaskDetails.Any(taskDetail => taskDetail.EndTask);

            return(isValid);
        }
Example #27
0
 public async Task RemoveProject(ProjectDetailModel project)
 {
     await _projectDetailsRepository.Delete(project);
 }
Example #28
0
 public async Task UpdateProjectDetails(int id, ProjectDetailModel project)
 {
     await _projectDetailsRepository.Update(id, project);
 }
Example #29
0
 public ProjectBuilder(IDesignRepoService designRepoService)
 {
     _designRepoService  = designRepoService;
     _designs            = new Dictionary <int, Design>();
     _projectDetailModel = new ProjectDetailModel();
 }