Esempio n. 1
0
        // email
        public EmailRequest GetEmail(Guid ConfirmationToken, string email)
        {
            EmailRequest emailRequest = new EmailRequest
            {
                FromEmail        = _configService.ConvertConfigValue_String("From_Email_Sabio"),
                FromName         = _configService.ConvertConfigValue_String("From_Name"),
                ToEmail          = email,
                Subject          = _configService.ConvertConfigValue_String("Subject"),
                EmailTemplate    = HostingEnvironment.MapPath("~/Content/ConfirmationEmailTemplate.html"),
                SendGridKey      = _configService.ConvertConfigValue_String("SendGrid_Key"),
                ConfirmationLink = _configService.ConvertConfigValue_String("URL_email_template") + ConfirmationToken,
            };

            return(emailRequest);
        }
        public ContactUsRequest Post(ContactUsAddRequest model)
        {
            ContactUsRequest contactusRequest = new ContactUsRequest
            {
                FromEmail = model.Email,
                FromName  = model.Name,
                ToEmail   = _configService.ConvertConfigValue_String("To_Email"),
                Subject   = model.Subject,
                Question  = model.Question,
                ContactUsEmailTemplate = HostingEnvironment.MapPath("~/Content/ContactUsEmailTemplate.html"),
                SendGridKey            = _configService.ConvertConfigValue_String("SendGrid_Key"),
            };

            return(contactusRequest);
        }
Esempio n. 3
0
        public HttpResponseMessage Login(LoginRequest model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var    webClient         = new WebClient();
                    string verification      = webClient.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", _configService.ConvertConfigValue_String("Google_Recaptcha"), model.recaptchaResponse));
                    var    recaptchaResponse = (JObject.Parse(verification)["success"].Value <bool>());

                    // checking for third party login
                    ThirdPartyUserLogin check = _thirdPartyUserService.GetByEmail(model.Email);
                    if (check.ThirdPartyTypeId > 0)
                    {
                        ErrorResponse resp = new ErrorResponse("Uncessful Login Attempt, user is registered with third party service");
                        return(Request.CreateResponse(HttpStatusCode.OK, resp));
                    }
                    else
                    {
                        IUserAuthData success = _userService.LogIn(model.Email, model.Password);

                        if (success != null)
                        {
                            List <int> pID = _userService.GetPerson(success.Id);
                            LoginResponse <IUserAuthData> resp = new LoginResponse <IUserAuthData>();
                            resp.Item     = success;
                            resp.PersonID = pID;
                            return(Request.CreateResponse(HttpStatusCode.OK, resp));
                        }
                        else
                        {
                            ErrorResponse resp = new ErrorResponse("Uncessful Login Attempt");
                            return(Request.CreateResponse(HttpStatusCode.OK, resp));
                        }
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }