public IActionResult Login(LoginViewModel loginViewModel) { if (!ModelState.IsValid) { return(View(loginViewModel)); } IList <string> errors = new List <string>(); SellerView seller = loginPersistence.PersistLogin(); if (seller == null) { if (EmailValidationService.IsValidEmail(loginViewModel.LoginInformation.Username)) { seller = eCommerce.GetSellerBy(loginViewModel.LoginInformation.Username); if (seller != null) { if (seller.Status == SellerStatus.Active) { string encryptedPassword = eCommerce.GetSellerEncryptedPassword(int.Parse(seller.Id)); if (EncryptionService.Encrypt(loginViewModel.LoginInformation.Password) == encryptedPassword) { loginPersistence.LoginThrough(loginViewModel.LoginInformation.Username, loginViewModel.LoginInformation.Remember); } else { errors.Add("Wrong password"); } } else { switch (seller.Status) { case SellerStatus.Locked: errors.Add("Account was locked"); break; case SellerStatus.Validating: errors.Add("Account are waiting for validating"); break; } } } else { errors.Add("Email not found"); } } else { errors.Add("Invalid email address"); } } else { return(Redirect(loginViewModel.ReturnUrl)); } if (errors.Any()) { ViewData[GlobalViewBagKeys.Errors] = errors; return(View(loginViewModel)); } return(Redirect(loginViewModel.ReturnUrl)); }
public SellerView PersistLogin() { SellerView seller; string sessionValue = session.GetString(sellerSessionKeyWord); if (sessionValue != null) { seller = eCommerce.GetSellerBy(int.Parse(sessionValue)); if (seller != null) { if (seller.Status != SellerStatus.Locked) { return(seller); } } session.Remove(sellerSessionKeyWord); return(null); } LoginCookies loginCookies = requestCookies.GetJson <LoginCookies>(sellerCookieKeyWord); if (loginCookies == null) { return(null); } seller = eCommerce.GetSellerBy(loginCookies.UserId); if (seller == null) { responseCookies.Delete(sellerCookieKeyWord); return(null); } if (seller.Status == SellerStatus.Locked) { responseCookies.Delete(sellerCookieKeyWord); return(null); } string loginValue = EncryptionService.Encrypt(seller.Email + eCommerce.GetSellerEncryptedPassword(int.Parse(seller.Id)) + connectionInfo.RemoteIpAddress.ToString()); if (loginCookies.LoginValue != loginValue) { responseCookies.Delete(sellerCookieKeyWord); return(null); } session.SetString(sellerSessionKeyWord, seller.Id); return(seller); }
public IActionResult Informations(int sellerId) { SellerView seller = eCommerce.GetSellerBy(sellerId); return(seller != null?View(seller) : (IActionResult)NotFound()); }
#pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() { BeginContext(30, 2, true); WriteLiteral("\r\n"); EndContext(); #line 3 "C:\Users\hando\Desktop\ECommerce\ECommerce.UI.MVC\Views\Product\Seller.cshtml" ECommerceService eCommerce = (ECommerceService)ViewData[GlobalViewBagKeys.ECommerceService]; SellerView seller = eCommerce.GetSellerBy((int)Model.SearchModel.SellerId); #line default #line hidden BeginContext(212, 4, true); WriteLiteral("<h1>"); EndContext(); BeginContext(217, 11, false); #line 7 "C:\Users\hando\Desktop\ECommerce\ECommerce.UI.MVC\Views\Product\Seller.cshtml" Write(seller.Name); #line default #line hidden EndContext(); BeginContext(228, 9, true); WriteLiteral("</h1>\r\n\r\n"); EndContext(); #line 9 "C:\Users\hando\Desktop\ECommerce\ECommerce.UI.MVC\Views\Product\Seller.cshtml" foreach (ProductView p in Model.Products) { #line default #line hidden BeginContext(284, 1, true); WriteLiteral("\t"); EndContext(); BeginContext(285, 43, false); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("partial", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "e7078fd35c05f11437ad043fe2fa58158490ccc48200", async() => { } ); __Microsoft_AspNetCore_Mvc_TagHelpers_PartialTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.PartialTagHelper>(); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_PartialTagHelper); __Microsoft_AspNetCore_Mvc_TagHelpers_PartialTagHelper.Name = (string)__tagHelperAttribute_0.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); #line 11 "C:\Users\hando\Desktop\ECommerce\ECommerce.UI.MVC\Views\Product\Seller.cshtml" __Microsoft_AspNetCore_Mvc_TagHelpers_PartialTagHelper.Model = p; #line default #line hidden __tagHelperExecutionContext.AddTagHelperAttribute("model", __Microsoft_AspNetCore_Mvc_TagHelpers_PartialTagHelper.Model, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); if (!__tagHelperExecutionContext.Output.IsContentModified) { await __tagHelperExecutionContext.SetOutputContentAsync(); } Write(__tagHelperExecutionContext.Output); __tagHelperExecutionContext = __tagHelperScopeManager.End(); EndContext(); BeginContext(328, 2, true); WriteLiteral("\r\n"); EndContext(); #line 12 "C:\Users\hando\Desktop\ECommerce\ECommerce.UI.MVC\Views\Product\Seller.cshtml" } #line default #line hidden BeginContext(333, 2, true); WriteLiteral("\r\n"); EndContext(); BeginContext(335, 283, false); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "e7078fd35c05f11437ad043fe2fa58158490ccc410089", async() => { BeginContext(610, 2, true); WriteLiteral("\r\n"); EndContext(); } ); __ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper = CreateTagHelper <global::ECommerce.UI.MVC.Infrastructure.PageLinkTagHelper>(); __tagHelperExecutionContext.Add(__ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper); #line 14 "C:\Users\hando\Desktop\ECommerce\ECommerce.UI.MVC\Views\Product\Seller.cshtml" __ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper.PageModel = Model.PagingInfo; #line default #line hidden __tagHelperExecutionContext.AddTagHelperAttribute("page-model", __ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper.PageModel, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); BeginWriteTagHelperAttribute(); #line 14 "C:\Users\hando\Desktop\ECommerce\ECommerce.UI.MVC\Views\Product\Seller.cshtml" WriteLiteral(ViewContext.RouteData.Values["Action"].ToString()); #line default #line hidden __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); __ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper.PageAction = __tagHelperStringValueBuffer; __tagHelperExecutionContext.AddTagHelperAttribute("page-action", __ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper.PageAction, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); __ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper.PageClass = (string)__tagHelperAttribute_2.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_2); __ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper.PageClassNormal = (string)__tagHelperAttribute_3.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_3); __ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper.PageClassSelected = (string)__tagHelperAttribute_4.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_4); __ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper.PageClassDisabled = (string)__tagHelperAttribute_5.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_5); if (__ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper.PageUrlValues == null) { throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("page-url-sellerId", "ECommerce.UI.MVC.Infrastructure.PageLinkTagHelper", "PageUrlValues")); } #line 17 "C:\Users\hando\Desktop\ECommerce\ECommerce.UI.MVC\Views\Product\Seller.cshtml" __ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper.PageUrlValues["sellerId"] = Model.SearchModel.SellerId; #line default #line hidden __tagHelperExecutionContext.AddTagHelperAttribute("page-url-sellerId", __ECommerce_UI_MVC_Infrastructure_PageLinkTagHelper.PageUrlValues["sellerId"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); if (!__tagHelperExecutionContext.Output.IsContentModified) { await __tagHelperExecutionContext.SetOutputContentAsync(); } Write(__tagHelperExecutionContext.Output); __tagHelperExecutionContext = __tagHelperScopeManager.End(); EndContext(); }