private void detach_sif_InviteProjectUsers(sif_InviteProjectUser entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
 partial void Deletesif_InviteProjectUser(sif_InviteProjectUser instance);
 partial void Updatesif_InviteProjectUser(sif_InviteProjectUser instance);
 partial void Insertsif_InviteProjectUser(sif_InviteProjectUser instance);
		private void attach_sif_InviteProjectUsers(sif_InviteProjectUser entity)
		{
			this.SendPropertyChanging();
			entity.Project = this;
		}
        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");
        }