コード例 #1
0
		private void detach_sif_InviteProjectUsers(sif_InviteProjectUser entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
コード例 #2
0
 partial void Deletesif_InviteProjectUser(sif_InviteProjectUser instance);
コード例 #3
0
 partial void Updatesif_InviteProjectUser(sif_InviteProjectUser instance);
コード例 #4
0
 partial void Insertsif_InviteProjectUser(sif_InviteProjectUser instance);
コード例 #5
0
		private void attach_sif_InviteProjectUsers(sif_InviteProjectUser entity)
		{
			this.SendPropertyChanging();
			entity.Project = this;
		}
コード例 #6
0
        public PartialViewResult InviteNewUser(string userEmail)
        {
            sif_InviteProjectUser newInvitation = new sif_InviteProjectUser();
            Project activeProject = Session["project"] as Project;
            User invitedUser;
            try
            {
                invitedUser = db.Users.Where(user => user.email.Trim() == userEmail.Trim()).Single();
            }
            catch (Exception)
            {
                TempData["ErrorInvitation"] = "User " + userEmail + " does not exist";
                return PartialView("InvitationStaus");
            }

            newInvitation.idProject = activeProject.idProject;
            newInvitation.idUser = invitedUser.idUser;

            var checkIfAlreadyInvited = from n in db.sif_InviteProjectUsers
                                        where n.idUser == invitedUser.idUser && n.idProject == activeProject.idProject
                                        select n;

            var checkIfAlreadyMember = from n in db.sif_ProjectUsers
                                       where n.idProject == activeProject.idProject && n.idUser == invitedUser.idUser
                                       select n;

            if (checkIfAlreadyInvited.Count() != 0)
            {
                TempData["ErrorInvitation"] = "User " + userEmail + " has already been invited on " + activeProject.projectName;
                return PartialView("InvitationStaus");
            }
            else if (checkIfAlreadyMember.Count() != 0)
            {
                TempData["ErrorInvitation"] = "User " + userEmail + " is already a member on " + activeProject.projectName;
                return PartialView("InvitationStaus");
            }
            else
            {
                db.sif_InviteProjectUsers.InsertOnSubmit(newInvitation);
                db.SubmitChanges();
                TempData["ErrorInvitation"] = "Invitation has been sent";
            }
            return PartialView("InvitationStaus");
        }