Exemplo n.º 1
0
        public async Task <ViewResult> Update(int id)
        {
            PanelUserFormModel model = new PanelUserFormModel
            {
                UserId = id
            };

            try
            {
                Result <PanelUserDTO> result = await _panelUserService.GetUserAsync(id);

                if (result.IsSuccess)
                {
                    model = Mapper.Map <PanelUserDTO, PanelUserFormModel>(result.Data);
                }
                else
                {
                    model.FormMessage = result.FormMessage;
                }
                model.UserId = id;
                FillPanelUserFormModel(model);
                return(this.View((object)model));
            }
            catch (Exception ex)
            {
                LoggerExtensions.LogError(_logger, ex, "GET Update Error {0}", new object[1]
                {
                    id
                });
                model.FormMessage = "İşleminiz gerçekleştirilemedi.";
                return(this.View((object)model));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Login(AdminLoginViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                try
                {
                    Result <PanelUserDTO> result = await _panelUserService.GetUserAsync(model.Email, model.Password);

                    if (!result.IsSuccess)
                    {
                        model.FormMessage = "E-Posta ya da Şifre bilgisi yanlış, lütfen bilgilerinizi kontrol edin.";
                        return(this.View((object)model));
                    }
                    PanelUserDTO data   = result.Data;
                    List <Claim> claims = new List <Claim>
                    {
                        new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", data.Id.ToString()),
                        new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", data.Name),
                        new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", data.Email),
                        new Claim("CompanyId", data.CompanyId.ToString()),
                        new Claim("PlaceId", data.PlaceId.ToString()),
                        new Claim("CompanyName", data.Company.Name),
                        new Claim("http://schemas.microsoft.com/ws/2008/06/identity/claims/role", data.Role.ToString())
                    };
                    ClaimsPrincipal claimsPrincipal = new ClaimsPrincipal(new ClaimsIdentity(claims, "ClaimIdentity"));
                    var             task            = AuthenticationHttpContextExtensions.SignInAsync(this.HttpContext, "AdminAreaCookies", claimsPrincipal);
                    task.Wait();
                    if (task.IsCompletedSuccessfully)
                    {
                        var temp = this.User.Claims;
                    }
                    else
                    {
                    }
                    return(this.RedirectToAction("Index", "Manage"));
                }
                catch (Exception ex)
                {
                    LoggerExtensions.LogError(_logger, ex, "Panel Login Error", Array.Empty <object>());
                    model.FormMessage = "İşleminiz gerçekleştirilemedi.";
                    return(this.View((object)model));
                }
            }
            return(this.View((object)model));
        }