Ejemplo n.º 1
0
        //[HttpPost]
        ////[ValidateAntiForgeryToken]
        //public AlzaAdminDTO ChangePassword([FromBody] ChangePasswordViewModel model)
        //{
        //    try
        //    {
        //        //VALIDACE MODELU
        //        if (!ModelState.IsValid)
        //            return InvalidModel();


        //        //OSTATNI
        //        var user = _userManager.GetUserAsync(User).Result;
        //        if (user == null)
        //            return ErrorDTO("user == null");


        //        //CHANGE PASSWORD
        //        var result = _userManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword).Result;
        //        if (!result.Succeeded)
        //            return InvalidIdentityResultDTO(result);


        //        _signInManager.SignInAsync(user, isPersistent: false);

        //        return AlzaAdminDTO.True;
        //    }
        //    catch (Exception e)
        //    {
        //        return ExceptionDTO(e);
        //    }
        //}



        //// GET: /Account/ConfirmEmail
        //[HttpGet]
        //[AllowAnonymous]
        //public async Task<IActionResult> ConfirmEmail(string userId, string code)
        //{
        //    try
        //    {
        //        if (userId == null)
        //            return ErrorActionResult("userId == null");

        //        if (code == null)
        //            return ErrorActionResult("code == null");


        //        var user = await _userManager.FindByIdAsync(userId);

        //        if (user == null)
        //            return ErrorActionResult("user == null");


        //        var result = await _userManager.ConfirmEmailAsync(user, code);

        //        if (!result.Succeeded)
        //        {

        //            if (result.Errors.First().Code == "InvalidToken")
        //            {
        //                return RedirectToAction("InvalidCode", "Error");
        //            }

        //            return InvalidIdentityResultActionResult(result);
        //        }



        //        return View("ConfirmEmail");
        //    }
        //    catch (Exception e)
        //    {
        //        return ExceptionActionResult(e);
        //    }
        //}

        ////
        //// GET: /Account/ForgotPassword
        //[HttpGet]
        //[AllowAnonymous]
        //public IActionResult ForgotPassword()
        //{
        //    try
        //    {
        //        /* if it is ajax call we want partial */
        //        if (Request.Headers["X-Requested-With"] == "XMLHttpRequest")
        //        {
        //            return PartialView("_ForgotPasswordPartial");
        //        }

        //        return View("ForgotPassword");
        //    }
        //    catch (Exception e)
        //    {
        //        return ExceptionActionResult(e);
        //    }
        //}


        ////
        //// POST: /Account/ForgotPassword
        //[HttpPost]
        //[AllowAnonymous]
        //[ValidateAntiForgeryToken]
        //public async Task<IActionResult> ForgotPassword(ForgotPasswordViewModel model)
        //{
        //    try
        //    {

        //        if (ModelState.IsValid)
        //        {
        //            var user = await _userManager.FindByNameAsync(model.Nickname);
        //            if (user == null || !(await _userManager.IsEmailConfirmedAsync(user)))
        //            {
        //                // Don't reveal that the user does not exist or is not confirmed
        //                return View("ForgotPasswordConfirmation");
        //            }

        //            // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713
        //            // Send an email with this link
        //            var code = await _userManager.GeneratePasswordResetTokenAsync(user);
        //            var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme);
        //            await _emailSender.SendEmailAsync(user.Email, "Reset Password",
        //               $"Please reset your password by clicking here: <a href='{callbackUrl}'>link</a>");
        //            return View("ForgotPasswordConfirmation");
        //        }

        //        // If we got this far, something failed, redisplay form
        //        return View(model);
        //    }
        //    catch (Exception e)
        //    {
        //        return ExceptionActionResult(e);
        //    }
        //}

        ////
        //// GET: /Account/ForgotPasswordConfirmation
        //[HttpGet]
        //[AllowAnonymous]
        //public IActionResult ForgotPasswordConfirmation()
        //{
        //    try
        //    {
        //        return View();
        //    }
        //    catch (Exception e)
        //    {
        //        return ExceptionActionResult(e);
        //    }
        //}

        ////
        //// GET: /Account/ResetPassword
        //[HttpGet]
        //[AllowAnonymous]
        //public IActionResult ResetPassword(string code = null)
        //{
        //    try
        //    {
        //        if (code == null)
        //            return ErrorActionResult("code == null");

        //        return View();
        //    }
        //    catch (Exception e)
        //    {
        //        return ExceptionActionResult(e);
        //    }
        //}

        ////
        //// POST: /Account/ResetPassword
        //[HttpPost]
        //[AllowAnonymous]
        //[ValidateAntiForgeryToken]
        //public async Task<IActionResult> ResetPassword(ResetPasswordViewModel model)
        //{
        //    try
        //    {
        //        if (!ModelState.IsValid)
        //        {
        //            return View(model);
        //        }
        //        var user = await _userManager.FindByNameAsync(model.Nickname);
        //        if (user == null)
        //        {
        //            // Don't reveal that the user does not exist
        //            return RedirectToAction(nameof(AccountController.ResetPasswordConfirmation), "Account");
        //        }
        //        var result = await _userManager.ResetPasswordAsync(user, model.Code, model.Password);
        //        if (!result.Succeeded)
        //            return InvalidIdentityResultActionResult(result);

        //        return RedirectToAction(nameof(AccountController.ResetPasswordConfirmation), "Account");
        //    }
        //    catch (Exception e)
        //    {
        //        return ExceptionActionResult(e);
        //    }
        //}

        ////
        //// GET: /Account/ResetPasswordConfirmation
        //[HttpGet]
        //[AllowAnonymous]
        //public IActionResult ResetPasswordConfirmation()
        //{
        //    try
        //    {
        //        return View();
        //    }
        //    catch (Exception e)
        //    {
        //        return ExceptionActionResult(e);
        //    }
        //}



        #region Helpers



        public void ErrorToModel(AlzaAdminDTO dto, LegoViewModel model)
        {
            model.ErrorNo = dto.errorNo;
            foreach (var item in dto.errors)
            {
                model.Errors.Add(item);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// HELPER return and log error
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public RedirectToActionResult ErrorActionResult(AlzaAdminDTO err)
        {
            _logger.LogError(err.errorNo + " - " + err.errorText);

            LegoViewModel model = new LegoViewModel();

            model.ErrorNo = err.errorNo;
            model.Errors.Add(err.errorText);

            return(RedirectToAction("someString", "someString", model));
        }
Ejemplo n.º 3
0
        public bool CanExecute(object parameter)
        {
            if (parameter == null)
            {
                return(false);
            }

            LegoViewModel = (LegoViewModel)parameter;

            return(LegoViewModel.IsCollecting);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// HELPER return and log error
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public RedirectToActionResult InvalidIdentityResultActionResult(IdentityResult result)
        {
            Guid          errNo = Guid.NewGuid();
            StringBuilder res   = new StringBuilder();

            foreach (var error in result.Errors)
            {
                res.AppendLine(error.Description);
            }

            _logger.LogError(errNo + " - " + res.ToString());


            LegoViewModel model = new LegoViewModel();

            model.ErrorNo = errNo;
            model.Errors.Add(res.ToString());

            return(RedirectToAction("someString", "someString", model));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// HELPER return and log error
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public IActionResult ExceptionActionResult(Exception e)
        {
            Guid errNo = Guid.NewGuid();

            _logger.LogError(errNo + " - " + e.Message + Environment.NewLine + e.StackTrace);


            LegoViewModel model = new LegoViewModel();

            model.ErrorNo = errNo;
            model.Errors.Add(e.Message + Environment.NewLine + e.StackTrace);



            /*************************************************************************/
            //BUG Notification

            //var userId = _userManager.GetUserId(User);
            //if (String.IsNullOrEmpty(userId))
            //    userId = "0";

            //var bug = new BugNotification
            //{
            //    UserProfileId = Int32.Parse(userId),
            //    Severity = "Critical",
            //    ErrorNo = errNo,
            //    CreatedDate = DateTime.Now,
            //    Note = e.Message + Environment.NewLine + e.StackTrace
            //};
            //_mediator.PublishAsync(bug);

            /*************************************************************************/



            return(new AlzaActionResult("someString", model));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// HELPER return and log error
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public IActionResult ErrorActionResult(string text)
        {
            Guid errNo = Guid.NewGuid();

            _logger.LogError(errNo + " - " + text);

            LegoViewModel model = new LegoViewModel();

            model.ErrorNo = errNo;
            model.Errors.Add(text);



            /*************************************************************************/
            //BUG Notification

            //var userId = _userManager.GetUserId(User);
            //if (String.IsNullOrEmpty(userId))
            //    userId = "0";

            //var bug = new BugNotification
            //{
            //    UserProfileId = Int32.Parse(userId),
            //    Severity = "Error",
            //    ErrorNo = errNo,
            //    CreatedDate = DateTime.Now,
            //    Note = text
            //};
            //_mediator.PublishAsync(bug);

            /*************************************************************************/



            //FINALni varianta Custom ActionResult
            return(new AlzaActionResult("someString", model));
        }
Ejemplo n.º 7
0
 public CloseCommand(LegoViewModel viewModel)
 {
     LegoViewModel = viewModel;
 }
Ejemplo n.º 8
0
 public EditCommand(LegoViewModel viewModel)
 {
     LegoViewModel = viewModel;
 }
Ejemplo n.º 9
0
 public OpenCommand(LegoViewModel viewModel)
 {
     LegoViewModel = viewModel;
 }
Ejemplo n.º 10
0
 public DeleteCommand(LegoViewModel viewModel)
 {
     LegoViewModel = viewModel;
 }