Esempio n. 1
0
        public ActionResult GetAllProjectsWorkType(long id)
        {
            // Get project workType
            Billing workType;
            var     getProject = _projectRepository.GetBy(u => u.Id == id);

            if (getProject.IsPublic == true)
            {
                workType = Billing.NonBillable;
            }
            else
            {
                var getProjectMember = _projectMemberRepository.GetBy(u => u.ProjectId == id);
                workType = getProjectMember.Billing;
            }
            return(Json(workType.ToString(), JsonRequestBehavior.AllowGet));
        }
        public ActionResult CreateProjectMember(ProjectMember projectMember)
        {
            if (projectMember.Id > 0)
            {
                var selectedProjectMember = _projectMemberRepository.Get(projectMember.Id);

                if (selectedProjectMember != null)
                {
                    selectedProjectMember.ProjectMemberRoleId = projectMember.ProjectMemberRoleId;
                    selectedProjectMember.Billing             = projectMember.Billing;
                    selectedProjectMember.Rate            = projectMember.Rate;
                    selectedProjectMember.EmployeeId      = projectMember.EmployeeId;
                    selectedProjectMember.UpdatedByUserId = WebUser.Id;
                    selectedProjectMember.MemberStatus    = projectMember.MemberStatus;
                    _projectMemberRepository.Update(selectedProjectMember);
                    _unitOfWork.Commit();
                    return(RedirectToAction("Details", "Projects", new { Id = projectMember.ProjectId }));
                }
            }
            else
            {
                if (ModelState.IsValid)
                {
                    var alreadyMember = _projectMemberRepository.GetBy(i => i.EmployeeId == projectMember.EmployeeId && i.ProjectId == projectMember.ProjectId);

                    if (alreadyMember == null)
                    {
                        projectMember.CreatedByUserId = WebUser.Id;
                        _projectMemberRepository.Create(projectMember);
                        _unitOfWork.Commit();

                        return(RedirectToAction("Details", "Projects", new { Id = projectMember.ProjectId }));
                    }
                    else
                    {
                        return(Json(false));
                    }
                }
            }
            return(View(projectMember));
        }