private async System.Threading.Tasks.Task InviteUser()
        {
            if (!HasErrors)
            {
                if (ProjectUsers.Any(nav => nav.EMail == NewUserEmail) || AllCompanyUsers.Any(nav => nav.EMail == NewUserEmail))
                {
                    ChangeNotification.Raise(new Notification
                    {
                        Title   = Properties.Resources.User_Invitation_Exists_Title,
                        Content = string.Format(Properties.Resources.User_Invitation_Exists_Content, NewUserEmail)
                    });
                }
                else
                {
                    try
                    {
                        User newUser = await adminService.InviteNewUserAsync(NewUserEmail, SelectedProject, globalModel.CurrentUser);

                        ProjectUsers.Add(mapper.Map <ProjectUser>(newUser));
                    }
                    catch (TimeoutException timeoutEx)
                    {
                        _eventAggregator.GetEvent <TimeoutErrorEvent>().Publish(timeoutEx);
                    }
                }
            }
        }
Esempio n. 2
0
        public IHttpActionResult CanInnerEdit(string projectId)
        {
            var canInnerEditRoleCodeList = new List <string>
            {
                ProjectUserRoleCode.AssetActor,
                ProjectUserRoleCode.AssetRep,
                ProjectUserRoleCode.AssetManager
            };
            var result = ProjectUsers.Any(pu => pu.ProjectId == projectId &&
                                          pu.UserAccount == ClientCookie.UserCode &&
                                          canInnerEditRoleCodeList.Contains(pu.RoleCode));

            if (result)
            {
                var project = VProject.Search(i => i.ProjectId == projectId).FirstOrDefault();
                if (project != null)
                {
                    switch (project.FlowCode)
                    {
                    case FlowCode.Closure:
                        result = !ProjectInfo.IsFlowStarted(projectId, FlowCode.Closure_ClosurePackage);
                        break;

                    case FlowCode.Renewal:
                        result = !ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Package);
                        break;
                    }
                }
            }
            return(Ok(result));
        }
Esempio n. 3
0
        /// <summary>
        /// Helper method to add a user to project users list
        /// </summary>
        /// <param name="user">The User who will be assigned to the project.</param>
        public void AssignUser(User user)
        {
            if (ProjectUsers.Any(aUser => aUser.UserId == user.Id))
            {
                return;
            }
            var associatedUser = Mapper.Map <ProjectUser>(user);

            ProjectUsers.Add(associatedUser);
        }
Esempio n. 4
0
        /// <summary>
        /// Helper method to initialize DateCreated, CreatedBy, LastEditedBy, and DateLastEdited properties
        /// </summary>
        /// <param name="user">The User who created the project.</param>
        public void SetCreatedDetails(User user)
        {
            var date = DateTime.UtcNow;

            CreatedBy      = user;
            DateCreated    = date;
            LastEditedBy   = user;
            DateLastEdited = date;
            if (ProjectUsers.Any(aUser => aUser.UserId == user.Id))
            {
                return;
            }
            var associatedUser = Mapper.Map <ProjectUser>(user);

            ProjectUsers.Add(associatedUser);
        }
Esempio n. 5
0
        public bool InRole(string projectId, string userCode, string roleCode)
        {
            var result = ProjectUsers.Any(pu => pu.ProjectId == projectId && pu.UserAccount == userCode && pu.RoleCode == roleCode);

            return(result);
        }