public ActionResult InviteUserToProjectPartial(UserViewModel user) { if (ModelState.IsValid) { var userForShared = _serviceUser.GetUserByID(user.UserId); var projectForShared = _serviceProject.GetProject(user.ProjectId); _currentUser = _serviceUser.GetUserByID(User.Identity.GetUserId()); _serviceProjectsShareService.AddUserToProjectsShare(projectForShared, userForShared, UserRoleProjectsShareConstants.Invited, _currentUser); var bodyMail = _currentUser.UserName + " invited you to a project!"; SmtpMailer.Instance(WebConfigurationManager.OpenWebConfiguration("~/web.config")).SendMail(userForShared.Email, "Invitation to project", bodyMail); ViewBag.PreviousPage = System.Web.HttpContext.Current.Request.UrlReferrer; return PartialView("Success"); } var users = _serviceProjectsShareService.GetUsersForSharedProject(_serviceProject.GetProject(user.ProjectId)); user.Users = Mapper.Map<IEnumerable<ApplicationUser>, IEnumerable<UsersListViewModel>>(users); return PartialView("_InviteUserToProjectPartial", user); }
public ActionResult InviteUserToProjectPartial(int id) { var users = _serviceProjectsShareService.GetUsersForSharedProject(_serviceProject.GetProject(id)); var usersViewModel = Mapper.Map<IEnumerable<ApplicationUser>, IEnumerable<UsersListViewModel>>(users); var model = new UserViewModel { Users = usersViewModel, ProjectId = id }; return PartialView("_InviteUserToProjectPartial", model); }