예제 #1
0
        public bool Send(EmailDto emailDto)
        {
            var result = true;

            try
            {
                foreach (var destination in emailDto.EmailAndTokenTo.Values)
                {
                    var mymsg = new EmailMessage("My Thai Star Restaurant booking stastus", "My Thai Star Restaurant", emailDto.EmailFrom, new List <string> {
                        destination
                    });

                    var body = PopulateEmailBody(emailDto, destination);


                    mymsg.AddBody(body, new List <string> {
                        GeFilePath("mui-email-inline.css"), GeFilePath("mui-email-styletag.css")
                    }, EmailBodyType.HtmlText);
                    mymsg.AddBody(body, new List <string>(), EmailBodyType.HtmlText);

                    var gmailMessageSender = new GoogleEmail();
                    gmailMessageSender.SendMessage(GmailServiceInstance, Credential.UserId, mymsg.GetEmailMessage());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{ex.Message} : {ex.InnerException}");
                result = false;
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Uses Google token service and validates the users details, providing a successful login if details are correct
        /// </summary>
        private void loginWorker()
        {
            string token = GoogleUser();

            JavaScriptSerializer decoder    = new JavaScriptSerializer();
            GoogleEmail          googleUser = decoder.Deserialize <GoogleEmail>(token);

            //If the data input is not empty, proceed
            if (googleUser != null)
            {
                string    email = lblEmail.Text = googleUser.data.email.ToLower(); //Convert tot lower case
                UserModel user  = UserBL.passUserSearch(email);                    //Acquire the user from the email address from the database

                //If the user found is not null, proceed
                if (user != null)
                {
                    Session["user"]  = user;
                    Session["login"] = user.Email;

                    string url = "AdminHome.aspx";

                    //Checks if a user is an administrator or standard user, and amends the next valid page to suit
                    if (user.AdminPermission == 1)
                    {
                        Session["loggedUser"] = "******";
                        url = "AdminHome.aspx";
                    }
                    if (user.AdminPermission == 0)
                    {
                        Session["loggedUser"] = "******";
                    }

                    Response.Redirect(url);
                }
            }
        }