Exemplo n.º 1
0
        public IHttpActionResult InsertGUID(ForgotPasswordAppTokenAddRequest model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                ItemResponse <string> response = new ItemResponse <string>
                {
                    Item = _appTokenService.InsertGUID(model)
                };

                if (response.Item != null)
                {
                    Email eml = new Email();

                    MessageAddress msgAdd = new MessageAddress
                    {
                        Email = model.Email
                                //,Name = model.Email
                    };

                    List <MessageAddress> list = new List <MessageAddress>
                    {
                        msgAdd
                    };

                    eml.To          = list;
                    eml.FromAddress = "*****@*****.**";
                    eml.FromName    = "Eleveight";
                    eml.Subject     = "Reset your password";
                    eml.HtmlBody    = _emailTemplateService.CreateForgotPassword(new EmailTemplateInput
                    {
                        Name  = msgAdd.Name,
                        Token = response.Item
                    });

                    _emailMessenger.SendMail(eml);
                }

                return(Ok(response));
            }
            catch (Exception ex)
            {
                int currentUser = _userService.GetCurrentUserId();
                _appLogService.Insert(new AppLogAddRequest
                {
                    AppLogTypeId = 1,
                    Message      = ex.Message,
                    StackTrace   = ex.StackTrace,
                    Title        = "Error in " + GetType().Name + " " + System.Reflection.MethodBase.GetCurrentMethod().Name,
                    UserBaseId   = currentUser
                });

                return(BadRequest(ex.Message));
            }
        }