Esempio n. 1
0
        public async Task <IActionResult> SubmitUpdateAccount(GoblinIdentityUpdateIdentityModel model, CancellationToken cancellationToken = default)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.WarningMessage = Messages.InvalidData;

                return(View("Account", model));
            }

            try
            {
                await GoblinIdentityHelper.UpdateIdentityAsync(LoggedInUser <GoblinIdentityUserModel> .Current.Data.Id, model, cancellationToken).ConfigureAwait(true);

                ViewBag.SuccessMessage = "Account Updated Successfully.";

                if (!string.IsNullOrWhiteSpace(model.NewPassword))
                {
                    return(View("~/Views/Auth/Login.cshtml", new LoginModel
                    {
                        Continue = Url.AbsoluteAction("Account", "Portal")
                    }));
                }
            }
            catch (GoblinException e)
            {
                ViewBag.ErrorMessage = e.ErrorModel.Message;
            }
            catch (Exception e)
            {
                ViewBag.ErrorMessage = e.Message;
            }

            return(View("Account", model));
        }