//Add an entry in the ACL, and send an invitation email public void SendInvitation(string email, Guid ProjectID, UserType userType, IEmailSender emailSender) { //Database access var db = new ApplicationDBContext(); //make sure this isnt a duplicate if (db.UsersAccessProjects.Where(acl => acl.Email == email && acl.ProjectID == ProjectID).Count() == 0) { //Working with ACL var acl = new UsersAccessProjects(); acl.Email = email; acl.invitationAccepted = false; acl.ProjectID = ProjectID; acl.UserID = null; //Save the ACL entry db.UsersAccessProjects.Add(acl); db.SaveChanges(); //build an invitaion email string body; body = "You have been invited to a new project.\n"; body += "Click the link to accept the invitation.\n"; body += "http://northcarolinataxrecoverycalculator.apphb.com/Project/AcceptInvite/" + acl.ID; //send an invitaion email emailSender.SendMail(email, "You have been invited to a project", body); } }
/// <summary> /// Allow collaborations on our project with a spcified user /// </summary> /// <param name="ProjectID"></param> /// <param name="EmailAddress"></param> /// <returns></returns> public UsersAccessProjects CreateCollaboration(Guid ProjectID, string EmailAddress) { var acl = new UsersAccessProjects(); acl.Email = EmailAddress; acl.invitationAccepted = false; acl.ProjectID = ProjectID; acl.UserID = null; //Save the ACL entry db.UsersAccessProjects.Add(acl); db.SaveChanges(); return acl; }
/// <summary> /// Send an invition via email to the invited user to collaborate on a project /// </summary> /// <param name="acl"></param> /// <param name="emailSender"></param> public void SendInvitation(UsersAccessProjects acl, IEmailSender emailSender) { //build an invitaion email. this is dirty :( string body; body = "You have been invited to a new project.\n"; body += "Click the link to accept the invitation.\n"; body += "http://northcarolinataxrecoverycalculator.apphb.com/Project/AcceptInvite/" + acl.ID; //send an invitaion email emailSender.SendMail(acl.Email, "You have been invited to a project", body); }
/// <summary> /// remove an invitation from teh DB if we no longer want to allow this user to collaborate with us on this project /// </summary> /// <param name="acl"></param> public void RevokeCollaboration(UsersAccessProjects acl) { db.UsersAccessProjects.Remove(acl); db.SaveChanges(); }