public DataResponse Process(PaymentPageModel model) { var result = _placeOrderSAL.Post(new PlaceOrder { CustomerID = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name), CountryID = Int32.Parse(_configuration["CountryID"]), TransactionID = "TempID" + DateTime.Now.TimeOfDay }); var email = _contactSAL.Search(new List <SearchParameter> { new SearchParameter { Name = "CustomerID", Value = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name) }, new SearchParameter { Name = "ContactTypeID", Value = (int)Model.Enum.Customer.ContactType.Email } }); var emailBody = _viewRenderService.RenderToStringAsync("Render/Receipt", new object()).Result; SmtpClient client = new SmtpClient("relay.hostinguk.net"); client.UseDefaultCredentials = true; MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress("*****@*****.**"); mailMessage.To.Add(email.FirstOrDefault().Value); mailMessage.BodyEncoding = Encoding.UTF8; mailMessage.SubjectEncoding = Encoding.UTF8; AlternateView htmlView = AlternateView.CreateAlternateViewFromString(emailBody); htmlView.ContentType = new ContentType("text/html"); mailMessage.Body = emailBody; mailMessage.AlternateViews.Add(htmlView); mailMessage.IsBodyHtml = true; mailMessage.Subject = "Your receipt from totalsmarthomes.com"; client.Send(mailMessage); return(new DataResponse { Type = Model.Enum.Response.DataResponseType.SUCCESS, Details = result.Details }); }
public DataResponse Process(LoginPageModel model) { var security = _securitySAL.Search(new List <SearchParameter> { new SearchParameter { Name = "Username", Value = Encryption.EncryptString(model.Email) }, new SearchParameter { Name = "Password", Value = Encryption.EncryptString(model.Password) } }); if (security != null) { if (security.Any()) { var user = security.FirstOrDefault(); var claims = new List <Claim> { new Claim(ClaimTypes.Name, user.CustomerID.ToString()), new Claim(ClaimTypes.Role, "Administrator"), }; var claimsIdentity = new ClaimsIdentity( claims, CookieAuthenticationDefaults.AuthenticationScheme); var authProperties = new Microsoft.AspNetCore.Authentication.AuthenticationProperties { //AllowRefresh = <bool>, // Refreshing the authentication session should be allowed. ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(10), // The time at which the authentication ticket expires. A // value set here overrides the ExpireTimeSpan option of // CookieAuthenticationOptions set with AddCookie. IsPersistent = true, // Whether the authentication session is persisted across // multiple requests. Required when setting the // ExpireTimeSpan option of CookieAuthenticationOptions // set with AddCookie. Also required when setting // ExpiresUtc. //IssuedUtc = <DateTimeOffset>, // The time at which the authentication ticket was issued. //RedirectUri = <string> // The full path or absolute URI to be used as an http // redirect response value. }; _httpContextAccessor.HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties); _basketTransferSAL.Post(new BasketTransfer { CustomerID = user.CustomerID, BasketGUID = GUID }); return(new DataResponse { Type = Model.Enum.Response.DataResponseType.SUCCESS, Details = "" }); } } return(new DataResponse() { Type = Model.Enum.Response.DataResponseType.UNAUTHENTICATED, Details = "" }); }
public IActionResult Register(RegisterPageModel model) { if (ModelState.IsValid) { var customer = _customerService.Post(new Customer { Forename = model.ForeName, Surname = model.SurName, }); if (customer.Type == StoreFront.Model.Enum.Response.DataResponseType.SUCCESS) { var customerID = Int32.Parse(customer.Details); var addressStatus = _invoiceAddressService.Post(new StoreFront.Model.APIModel.Customer.InvoiceAddress { CustomerID = customerID, Address1 = model.Address1, Address2 = model.Address2 ?? "", Address3 = model.Address3 ?? "", Address4 = model.Town, Address5 = "", Postcode = model.Postcode }); var contactStatus = _contactService.Post(new Contact { CustomerID = customerID, Value = model.Email, ContactTypeID = 1 }); var securityStatus = _securityService.Post(new Security { CustomerID = customerID, Username = Encryption.EncryptString(model.Email), Password = Encryption.EncryptString(model.Password) }); var page = (StoreFront.Service.Register.Register)_page; var transferStatus = _transferService.Post(new BasketTransfer { BasketGUID = page.GUID, CustomerID = customerID }); var claims = new List <Claim> { new Claim(ClaimTypes.Name, customerID.ToString()), new Claim(ClaimTypes.Role, "Administrator"), }; var claimsIdentity = new ClaimsIdentity( claims, CookieAuthenticationDefaults.AuthenticationScheme); var authProperties = new AuthenticationProperties { //AllowRefresh = <bool>, // Refreshing the authentication session should be allowed. ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(10), // The time at which the authentication ticket expires. A // value set here overrides the ExpireTimeSpan option of // CookieAuthenticationOptions set with AddCookie. IsPersistent = true, // Whether the authentication session is persisted across // multiple requests. Required when setting the // ExpireTimeSpan option of CookieAuthenticationOptions // set with AddCookie. Also required when setting // ExpiresUtc. //IssuedUtc = <DateTimeOffset>, // The time at which the authentication ticket was issued. //RedirectUri = <string> // The full path or absolute URI to be used as an http // redirect response value. }; HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties); return(RedirectToAction("Index", "Delivery")); } } return(View("Index", _page.Load(model))); }