public HttpResponse DeleteInvite(string invite)
        {
            string response;

            if (AuthTokens[0] != "demo")
            {
                CounselorInviteClient cic         = new CounselorInviteClient();
                CounselorInvite       inviteEntry = cic.GetByPartitionAndRowKey("invite", invite);
                if (inviteEntry != null)
                {
                    cic.Delete(inviteEntry);
                    response = "{\"result\": \"done\"}";
                }
                else
                {
                    response = "{\"result\": \"error\"}";
                }
            }
            else
            {
                response = "{\"result\": \"done\"}";
            }
            Response.ContentType = "application/json";
            Response.Write(response);
            Response.End();
            return(null);
        }
 public ActionResult Index(IEnumerable <string> firstname, IEnumerable <string> lastname, IEnumerable <string> email)
 {
     if (AuthTokens[0] == "demo")
     {
         ViewBag.DemoNextStep = NextStep("!");
         return(View());
     }
     if (firstname != null && lastname != null && email != null)
     {
         if (firstname.Count() == lastname.Count() && firstname.Count() == email.Count())
         {
             CounselorInviteClient cic   = new CounselorInviteClient();
             AdminAccountClient    aac   = new AdminAccountClient();
             UserAccountClient     uac   = new UserAccountClient();
             AdminAccount          admin = aac.GetByPartitionAndRowKey("admin", AuthTokens[1].ToLower());
             UserAccount           user  = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(AuthTokens[1].ToLower()), AuthTokens[1].ToLower());
             string school = admin.School;
             for (var i = 0; i < firstname.Count(); i++)
             {
                 string emailLower = email.ElementAt(i).ToLower();
                 string guid       = ShortGuidGenerator.NewGuid();
                 cic.AddNewItem(new CounselorInvite {
                     FirstName = firstname.ElementAt(i), LastName = lastname.ElementAt(i), Email = emailLower, School = school, RowKey = guid
                 });
                 SendInviteEmail(email.ElementAt(i).ToLower(), firstname.ElementAt(i) + " " + lastname.ElementAt(i), user.FirstName + " " + user.LastName, guid);
             }
             return(View());
         }
     }
     ViewBag.ErrorMessage = "error";
     return(View());
 }
        public HttpResponse ResendEmail(string invite)
        {
            string response;

            if (AuthTokens[0] != "demo")
            {
                CounselorInviteClient cic         = new CounselorInviteClient();
                CounselorInvite       inviteEntry = cic.GetByPartitionAndRowKey("invite", invite);
                if (inviteEntry != null)
                {
                    UserAccountClient uac  = new UserAccountClient();
                    UserAccount       user = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(AuthTokens[1].ToLower()), AuthTokens[1].ToLower());
                    SendInviteEmail(inviteEntry.Email, inviteEntry.FirstName + " " + inviteEntry.LastName, user.FirstName + " " + user.LastName, inviteEntry.RowKey);
                    response = "{\"result\": \"done\"}";
                }
                else
                {
                    response = "{\"result\": \"error\"}";
                }
            }
            else
            {
                response = "{\"result\": \"done\"}";
            }
            Response.ContentType = "application/json";
            Response.Write(response);
            Response.End();
            return(null);
        }
Exemplo n.º 4
0
 public ActionResult Counselor(string id)
 {
     if (id != null)
     {
         CounselorInviteClient cic    = new CounselorInviteClient();
         CounselorInvite       invite = cic.GetByPartitionAndRowKey("invite", id);
         if (invite != null)
         {
             ViewBag.Invite = invite;
             return(View());
         }
     }
     return(RedirectToAction("Index", "Home"));
 }
Exemplo n.º 5
0
        public ActionResult Counselor(FormCollection collection)
        {
            string                adminEmail = "";
            UserAccountClient     uac        = new UserAccountClient();
            CounselorInviteClient cic        = new CounselorInviteClient();
            SchoolAccountClient   sac        = new SchoolAccountClient();
            UserAccount           account    = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(collection["email"].ToLower()), collection["email"].ToLower());
            CounselorInvite       invite     = cic.GetByPartitionAndRowKey("invite", collection["invite"]);
            SchoolAccount         school     = sac.GetByPartitionAndRowKey("school", collection["school"]);

            if (invite != null)
            {
                if (invite.Email == collection["email"].ToLower())
                {
                    if (account == null)
                    {
                        uac.AddNewItem(new UserAccount {
                            PartitionKey = UserAccountClient.GetPartitionKeyForEmail(collection["email"].ToLower()), RowKey = collection["email"].ToLower(), FirstName = collection["firstname"], LastName = collection["lastname"], Email = collection["email"], Password = collection["password"], ProfileType = "counselor", EmailConfirmed = true
                        });
                        CounselorAccountClient сac   = new CounselorAccountClient();
                        AdminAccountClient     aac   = new AdminAccountClient();
                        AdminAccount           admin = aac.GetBySchool(collection["school"]);
                        if (admin != null)
                        {
                            adminEmail = admin.RowKey;
                        }
                        сac.AddNewItem(new CounselorAccount {
                            RowKey = collection["email"].ToLower(), PhoneNumber = collection["phonenumber"], PhoneExtension = collection["extension"], School = collection["school"]
                        });
                        cic.Delete(invite);
                    }
                    else
                    {
                        ViewBag.Invite       = invite;
                        ViewBag.ErrorMessage = "There is an account already associated with this email. Please log in instead.";
                        return(View());
                    }
                }
                else
                {
                    ViewBag.Invite     = invite;
                    ViewBag.EmailMatch = "Email has to match";
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }

            string sessionkey = ClientSession.GetClientSessionKey("user", collection["email"].ToLower(), collection["firstname"] + " " + collection["lastname"], "counselor");

            Response.Cookies["sessionkey"].Value        = sessionkey;
            Response.Cookies["sessionkey"].Expires      = DateTime.UtcNow.AddDays(7);
            Response.Cookies["sessionusername"].Value   = collection["email"].ToLower();
            Response.Cookies["sessionusername"].Expires = DateTime.UtcNow.AddDays(7);
            Response.Cookies["cbnvm"].Value             = "1";
            Response.Cookies["cbnvm"].Expires           = DateTime.UtcNow.AddDays(7);
            SendCongratulationsEmailToCounselor(collection["email"], collection["firstname"] + " " + collection["lastname"]);
            SendUpdateEmailToAdmin(adminEmail, collection["firstname"] + " " + collection["lastname"]);

            EmailManager emailManager = new EmailManager();
            string       schooStr     = "";

            if (school != null)
            {
                schooStr = "<p>School name: " + school.SchoolName + "</p>";
            }
            string str = "<p>Full name: " + collection["firstname"] + " " + collection["lastname"] + "</p><p>Email: " + collection["email"] + "</p><p>Phone Number: " + collection["phonenumber"] + "</p><p>" + collection["extension"] + "</p>" + schooStr;

            emailManager.SendMail("*****@*****.**", "Admin", "*****@*****.**", "HS Counselor", str);
            TempData["counselor"] = true;
            return(RedirectToAction("Index", "CounselorPortal"));
        }