public ActionResult ForgetPassword(Companydetail Reg, string command) { if (ModelState.IsValidField("UserEmail")) { CustomerRegister cust_reg = new CustomerRegister(); if (command == "Reset Password") { TempData["UserData"] = cust_reg.forgetpassword(Reg); Companydetail CheckedUser = TempData["Userdata"] as Companydetail; string phone = CheckedUser.User_PhoneNumber; TempData["Phone"] = phone; if (phone == null) //dont get valu data base show error message { TempData["Error"] = "User is Not exist Plz Try Again"; return(RedirectToAction("ForgetPassword", "Registration")); } else //if user is valid then send code and redirect in verify code { TempData["RegistrationRole"] = command; TempData.Keep(); sendmail(); return(RedirectToAction("VerfyCode", "Registration", new { id = Session["LoginId"] })); } } } return(View()); }
public ActionResult Register(CustomerRegister c) { if (ModelState.IsValid) { // Kiểm tra nếu có tài khoản đăng ký email này rồi if (_customer.GetBy(x => x.Email == c.Email).Count() > 0) { ModelState.AddModelError("Email", "Email đã tồn tại!"); return(View()); } Customer _c = new Customer(); _c.FirstName = c.FirstName; _c.LastName = c.LastName; _c.Email = c.Email; _c.Password = c.Password; if (_customer.Add(_c)) { Helper.SendEmail(c.Email, "*****@*****.**", "tuhouse0710", "[Đăng ký tài khoản]", String.Format(@" <h1>Đăng ký tài khoản thành công!</h1> <b>Email đăng ký: </b> {0} ", c.Email)); return(RedirectToAction("Login")); } return(View()); } return(View()); }
public ActionResult Register([Bind(Include = "Email,Password,CompanyName,ContactName,ContactTitle,Address,City,Region,PostalCode,Country,Phone,Fax")] CustomerRegister customerRegister) { // Add new customer to database using (NorthwindEntities db = new NorthwindEntities()) { if (ModelState.IsValid) { Customer customer = customerRegister.MapToCustomer(); // First, make sure that the customer is unique if (db.Customers.Any(c => c.CompanyName == customer.CompanyName)) { // duplicate CompanyName return(View()); } // Generate guid for this customer customer.UserGuid = System.Guid.NewGuid(); // Hash & Salt the customer Password using SHA-1 algorithm customer.Password = UserAccount.HashSHA1(customer.Password + customer.UserGuid); // Save customer to database db.Customers.Add(customer); db.SaveChanges(); return(RedirectToAction(actionName: "Index", controllerName: "Home")); } // validation error return(View()); } }
public async Task <IHttpActionResult> PutCustomerRegister(int id, CustomerRegister customerRegister) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customerRegister.id) { return(BadRequest()); } db.Entry(customerRegister).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerRegisterExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ServiceDataWrapper <AuthenticationResult> CustomerRegistration(CustomerRegister register) { return(new ServiceDataWrapper <AuthenticationResult> { value = _service.RegisterAsync(register).Result }); }
public ActionResult Register(CustomerRegister customerRegister) { using (NORTHWNDEntities db = new NORTHWNDEntities()) { if (ModelState.IsValid) { Customer customer = Mapper.Map <Customer>(customerRegister); //Check for duplicate Registration (Name already in DB) if (db.Customers.Any(c => c.CompanyName == customer.CompanyName)) { ModelState.AddModelError("CompanyName", "There is already a company named that"); return(View()); } // Generate guid for this customer customer.UserGuid = System.Guid.NewGuid(); // Generate hash (with guid + pass) customer.Password = UserAccount.HashSHA1(customer.Password + customer.UserGuid); //Add Customer and Save Changes db.Customers.Add(customer); db.SaveChanges(); return(RedirectToAction(actionName: "Index", controllerName: "Home")); } return(View()); } }
public ActionResult CustomerRegister(CustomerRegister customerRegister) { var req = Mapper.Map <RegisterRequest>(customerRegister); var result = apiCaller.Call <RegisterRequest, RegisterResponse>(Model.Web.DashboardAPIControllers.Authentication, "Register", HttpMethod.Post, new RegisterRequest() { Email = customerRegister.Email, Password = customerRegister.Password, RegisterDate = DateTime.Now, }); if (result.Status == Model.ResponseStatus.Success) { return(View("Login", new CustomerLogin() { EndUserMessage = result.EndUserMessage, Status = result.Status })); } else { CustomerRegister customerRegisterResponse = new CustomerRegister(); customerRegisterResponse.Status = result.Status; if (result.EndUserMessage != null) { customerRegisterResponse.EndUserMessage = result.EndUserMessage; } else { customerRegisterResponse.EndUserMessage = "Api Connection Problem!"; } return(View("Register", customerRegisterResponse)); } }
public ActionResult Index([Bind(Include = " PersonKey, PersonLastName, PersonFirstName,PersonEmail, PersonPhone,PersonDateAdded")] CustomerRegister cr) { //connecting database of bakery BakeryEntities db = new BakeryEntities(); Person p = new Person(); p.PersonLastName = cr.PersonLastName; p.PersonFirstName = cr.PersonFirstName; var email = (from pl in db.People where pl.PersonLastName.Equals(cr.PersonLastName) || pl.PersonFirstName.Equals(cr.PersonFirstName) || pl.PersonEmail.Equals(cr.PersonEmail) select pl.PersonEmail).FirstOrDefault(); var phone = (from pl in db.People where pl.PersonLastName.Equals(cr.PersonLastName) || pl.PersonFirstName.Equals(cr.PersonFirstName) || pl.PersonPhone.Equals(cr.PersonPhone) select pl.PersonPhone).FirstOrDefault(); //checking if the personkey existed by comparing the input email and phone if (email == cr.PersonEmail || phone == cr.PersonPhone) { Message msg = new Message("Account Existed"); return(RedirectToAction("Result", msg)); } p.PersonEmail = cr.PersonEmail; p.PersonPhone = cr.PersonPhone; p.PersonDateAdded = DateTime.Now; db.People.Add(p); db.SaveChanges(); Message m = new Message(); m.MessageText = "Thank you, the book has been added"; return(View("Result", m)); }
public ActionResult AdminProfileSetting(Users user) { ModelState["VehicleNumber"].Errors.Clear(); ModelState["user_comp_type"].Errors.Clear(); ModelState["user_comp"].Errors.Clear(); ModelState["user_City"].Errors.Clear(); ModelState["UserCnic"].Errors.Clear(); ModelState["UserEmail"].Errors.Clear(); ModelState["User_PhoneNumber"].Errors.Clear(); ModelState["CompanyPhoneNumber"].Errors.Clear(); ModelState["PinCode"].Errors.Clear(); var method = new CustomerRegister(); string message = ""; var SavePath = ""; if (ModelState.IsValid) { if (user.image_file != null) { var FileLength = user.image_file.ContentLength; var FileContentType = user.image_file.ContentType; var extension = Path.GetExtension(user.image_file.FileName).ToLower(); var FileName = Path.GetFileNameWithoutExtension(user.image_file.FileName); FileName = FileName + DateTime.Now.ToString("yymmssfff") + extension; var FolderName = Server.MapPath("~/Pictures/Registeration/"); SavePath = Path.Combine(FolderName, FileName); user.Image = SavePath.ToString(); } try { message = method.UpdateUser(user); if (message == "1") { if (user.image_file != null) { user.image_file.SaveAs(SavePath); } message = "Admin Updated Successfully"; TempData["message"] = message; } else if (message == "0") { message = "Not Updated"; TempData["message"] = message; } } catch (Exception e) { TempData["message"] = e.Message; } } return(View(user)); }
public ActionResult AdminProfileSetting(int id = 0) { //int user_id=int.Parse(Session["user_Id"].ToString()); var method = new CustomerRegister(); Users edituser = method.EditUser(id); return(View(edituser)); }
public async Task <ActionResult> DeleteConfirmed(int id) { CustomerRegister customerRegister = await db.CustomerRegister.FindAsync(id); db.CustomerRegister.Remove(customerRegister); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <IHttpActionResult> GetCustomerRegister(int id) { CustomerRegister customerRegister = await db.CustomerRegister.FindAsync(id); if (customerRegister == null) { return(NotFound()); } return(Ok(customerRegister)); }
public async Task <ActionResult> Edit([Bind(Include = "id,name,email,phone")] CustomerRegister customerRegister) { if (ModelState.IsValid) { db.Entry(customerRegister).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(customerRegister)); }
public async Task <ActionResult> Create([Bind(Include = "id,name,email,phone")] CustomerRegister customerRegister) { if (ModelState.IsValid) { db.CustomerRegister.Add(customerRegister); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(customerRegister)); }
public async Task <IHttpActionResult> PostCustomerRegister(CustomerRegister customerRegister) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CustomerRegister.Add(customerRegister); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = customerRegister.id }, customerRegister)); }
public async Task <ActionResult> RegisterCustomer(CustomerRegister customerRegister) { //Console.WriteLine(User.Identity.IsAuthenticated); string organization = Request.Headers["organization"]; Organization orgExist = await _organizationRepository.OraganizationExist(organization); if (orgExist != null) { var user = new ApplicationUser { Email = customerRegister.Email, DatabaseName = organization, UserName = customerRegister.UserName, OrganizationId = orgExist.Id, }; var result = await _userManager.CreateAsync(user, customerRegister.Password); if (result.Succeeded) { var roleCustomer = "Customer"; await _management.AddRoleToUserAsync(roleCustomer, user); var Customer = new Customer() { customer_id = user.Id, name = customerRegister.name, phone_number = customerRegister.phoneNumber, email = customerRegister.Email, DateOfBirth = customerRegister.DateOfBirth, loyality_points = 0, type = 0, is_lead = false, }; byte[] error = new byte[500]; int status = await _customerRepository.Create(Customer, error); if (status != 0) { string z = Encoding.ASCII.GetString(error); string y = z.Remove(z.IndexOf('\0')); return(BadRequest(y)); } return(Ok()); } } return(BadRequest("error")); }
public IActionResult CustomerRegistration(CustomerRegister register) { var authResponse = _proxy.CustomerRegistration(register); if (authResponse.Errors == null) { var confirmationLink = Url.Action("ConfirmEmail", "Account", new { userId = authResponse.Id, token = authResponse.EmailConfirmationToken }, Request.Scheme); _logger.LogInformation("Email confirmation token:" + confirmationLink); TempData["Message"] = "Verify your email address"; return(Redirect("/account/login")); } ViewBag.Message = string.Join(",", authResponse.Errors); return(View()); }
public async Task <IHttpActionResult> DeleteCustomerRegister(int id) { CustomerRegister customerRegister = await db.CustomerRegister.FindAsync(id); if (customerRegister == null) { return(NotFound()); } db.CustomerRegister.Remove(customerRegister); await db.SaveChangesAsync(); return(Ok(customerRegister)); }
// GET: Admin/CustomerRegisters/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomerRegister customerRegister = await db.CustomerRegister.FindAsync(id); if (customerRegister == null) { return(HttpNotFound()); } return(View(customerRegister)); }
public IActionResult Register(CustomerRegister customer) { var newCustomer = new Customer { FirstName = customer.FirstName, LastName = customer.LastName, Username = customer.Username, email = customer.email, LocationId = customer.LocationId }; _customerRepository.Register(newCustomer, customer.password); _customerRepository.CommitChanges(); return(Accepted(newCustomer)); }
public ActionResult Register(CustomerRegister model) { if (ModelState.IsValid) { CustomerSession user = model.RegisterInDB(); if (user != null) { SessionManager.Instance.LoggedUser = user; return(RedirectToAction("Index", "Home")); } } return(View(new CustomerRegister())); }
public ActionResult UpdatePassword(Companydetail Reg, string user_ph) { user_ph = (TempData["Phone"].ToString()); CustomerRegister cust_reg = new CustomerRegister(); string check = cust_reg.UpdatePassword(Reg, user_ph); if (check == "1") { TempData["updatemessage"] = "Password Updated Successfully"; } else { TempData["updatemessage"] = "Problem"; } return(RedirectToAction("Login", "Registration", new { id = Session["LoginId"] })); }
public ActionResult CustomerRegister([Bind(Include = "Id,UserId,FirstName,LastName,DateOfBirth,Gender,PhoneNumber,Address,City,State,ZipCode,UserName,Password,ConfirmPassword,SecretQuestions,Answer,RegisterDate")] CustomerRegister customerRegister, string UserRole) { if (ModelState.IsValid) { if (UserRole == "Customer") { db.CustomerRegisters.Add(customerRegister); db.SaveChanges(); return(RedirectToAction("CustomerLogin")); } } else { ModelState.AddModelError(" ", "pass the correct user role"); } return(View()); }
public ActionResult AdminRegister(Companydetail Reg, string command) { if (command == "Register") { ModelState["PinCode"].Errors.Clear(); ModelState["VehicleNumber"].Errors.Clear(); if (ModelState.IsValid) { CustomerRegister Admin = new CustomerRegister(); string userexist = Admin.register(Reg); if (userexist == "0") { TempData["Erroruserexist"] = "User is already exist ,Plz login"; return(RedirectToAction("AdminRegister", "Registration")); } else { PictureSave(Reg); if (TempData["extensionerror"] == null) { TempData["RegistrationRole"] = command; TempData.Keep(); sendmail(); return(RedirectToAction("VerfyCode", "Registration")); } else { return(RedirectToAction("AdminRegister", "Registration")); } } } } return(View()); }
/// <summary> /// /// </summary> /// <param name="register"></param> /// <returns></returns> public async Task <AuthenticationResult> RegisterAsync(Register register) { ApplicationUser applicationUser; switch (register.Role) { case ApplicationConstant.ApplicationRoles.Customer: CustomerRegister customerRegister = (CustomerRegister)register; applicationUser = new ApplicationUser { UserName = customerRegister.Email, Email = customerRegister.Email, ContactNo = customerRegister.ContactNo, AddressLine1 = customerRegister.AddressLine1, AddressLine2 = customerRegister.AddressLine2, City = customerRegister.City, State = customerRegister.State, Zipcode = customerRegister.Zipcode }; return(await _repository.RegisterAsync(applicationUser, register.Password, register.Role)); case ApplicationConstant.ApplicationRoles.Retailer: RetailerRegister retailerRegister = (RetailerRegister)register; applicationUser = new ApplicationUser { UserName = retailerRegister.Email, Email = retailerRegister.Email, ContactNo = retailerRegister.ContactNo, BusinessEmail = retailerRegister.BusinessEmail, AddressLine1 = retailerRegister.BusinessAddressLine1, AddressLine2 = retailerRegister.BusinessAddressLine2, City = retailerRegister.City, State = retailerRegister.State, Zipcode = retailerRegister.Zipcode }; return(await _repository.RegisterAsync(applicationUser, register.Password, register.Role)); } return(null); }
/// <summary> /// Loads CustomerRegister and clear the temporary list TempIncomeList /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnChoseCustomer_Click(object sender, RoutedEventArgs e) { CustomerRegister customerRegister = new CustomerRegister(true); if (customerRegister.ShowDialog() == true) { dgIncomeProduct.IsEnabled = true; SelectedCustomer = customerRegister.SelectedCustomer; FinancialIncomeList = new ObservableCollection <FinancialIncome>(RevenueManagement.Instance.GetFinancialIncomesByCustomer(SelectedCustomer.CustomerID)); dgIncomeProduct.ItemsSource = FinancialIncomeList; lblCustomerID.Content = SelectedCustomer.CustomerID; lblCustomerName.Content = SelectedCustomer.CustomerName; LockPrimaryCells(); if (CurrentFinancialIncomeYear.FinancialIncomeLock == false) { btnDelete.IsEnabled = true; btnSave.IsEnabled = true; } UpdateLabels(); } }
public ActionResult PasswordUpdate(int id, NewPassword newPassword) { CustomerRegister user1 = new CustomerRegister(); if (!ModelState.IsValid) { return(View()); } else { if (newPassword != null) { user1 = db.CustomerRegisters.FirstOrDefault(x => x.UserId == id); user1.Password = newPassword.Password; user1.ConfirmPassword = newPassword.ConfirmPassword; methods.Save(db); ViewBag.msg = "Password Reset Successfully"; return(View()); } ModelState.AddModelError("", "Invalid Credentials."); return(View()); } }
public void Register(CustomerRegisterViewModel customerRegisterViewModel) { var existingStatus = unitOfWork.CustomerregisterRepository.Get().FirstOrDefault(x => x.CustomerPhone == customerRegisterViewModel.CustomerPhone); var isDuplicateDescription = existingStatus != null; if (isDuplicateDescription) { customerRegisterViewModel.Errormessage = "Phone Number Are Exists"; } else { byte[] data = UTF8Encoding.UTF8.GetBytes(customerRegisterViewModel.Password); using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider()) { byte[] keys = md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(hash)); using (TripleDESCryptoServiceProvider TripDes = new TripleDESCryptoServiceProvider() { Key = keys, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7 }) { ICryptoTransform transform = TripDes.CreateEncryptor(); byte[] result = transform.TransformFinalBlock(data, 0, data.Length); var customerregister = new CustomerRegister { CustomerEmail = customerRegisterViewModel.CustomerEmail, CustomerPhone = customerRegisterViewModel.CustomerPhone, Password = Convert.ToBase64String(result, 0, result.Length) }; unitOfWork.CustomerregisterRepository.Insert(customerregister); unitOfWork.Save(); } } } //MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); //var utf8 = new UTF8Encoding(); //byte[] data = md5.ComputeHash(utf8.GetBytes(customerRegisterViewModel.Password)); // var customerregister = new CustomerRegister // { // CustomerEmail = customerRegisterViewModel.CustomerEmail, // CustomerPhone = customerRegisterViewModel.CustomerPhone, // Password = Convert.ToBase64String(data) // }; // unitOfWork.CustomerregisterRepository.Insert(customerregister); // unitOfWork.Save(); //} }
public async Task <ActionResult> Register(CustomerRegister customerRegister) { string OrganizationName = (string)RouteData.Values["OrganizationName"]; Organization orgExist = await _organizationRepository.OraganizationExist(OrganizationName); ViewBag.Organization = OrganizationName; if (orgExist != null) { var user = new ApplicationUser { Email = customerRegister.Email, DatabaseName = OrganizationName, UserName = customerRegister.UserName, OrganizationId = orgExist.Id, }; var result = await _userManager.CreateAsync(user, customerRegister.Password); if (result.Succeeded) { var roleCustomer = "Customer"; var claims = new List <Claim> { new Claim(ClaimTypes.Name, user.UserName), new Claim(ClaimTypes.NameIdentifier, user.Id), new Claim(ClaimTypes.Role, roleCustomer), new Claim("organization", orgExist.Name), }; var claimsIdentity = new ClaimsIdentity(claims, OrganizationName); var authProperties = new AuthenticationProperties(); await Task.WhenAll( new Task[] { _management.AddRoleToUserAsync(roleCustomer, user), HttpContext.SignInAsync(OrganizationName, new ClaimsPrincipal(claimsIdentity), authProperties) }); var Customer = new Customer() { customer_id = user.Id, name = customerRegister.name, phone_number = customerRegister.phoneNumber, email = customerRegister.Email, DateOfBirth = customerRegister.DateOfBirth, loyality_points = 0, type = 0, is_lead = false, }; byte[] error = new byte[500]; _customerRepository.setConnectionString(OrganizationName); int status = await _customerRepository.Create(Customer, error); if (status != 0) { return(StatusCode(500)); } muserLogger.LogInformation("A user with a specifc roles : " + roleCustomer + " has Been Created"); return(LocalRedirect("~/Store/" + orgExist.Name)); } var errors = result.Errors.ToList(); foreach (var el in errors) { ModelState.AddModelError("", el.Code); } } else { return(NotFound("This organization does not exist")); } return(View("CustomerRegister")); }
public async Task <IResponseContent> CustomerRegisterAsync( string tenantUid, string origin, string email, string username, string password, string mobile = "", string title = "", string firstName = "", string lastName = "", string gender = "", string dob = "", string address1 = "", string address2 = "", string address3 = "", string town = "", string county = "", string postCode = "", string currency = "", string odds = "", string language = "", string country = "", string timeZone = "", string bonusCode = "", string referrer = "", string notify = "", string notifyViaPlatform = "", string notifyViaEmail = "", string notifyViaSMS = "", string authorization = "" ) { var customer = new CustomerRegister { AddressLine1 = address1, AddressLine2 = address2, AddressLine3 = address3, CountryCode = country, County = county, CurrencyCode = currency, DOB = dob, Email = email, FirstName = firstName, Gender = gender, LanguageCode = language, LastName = lastName, Mobile = mobile, Password = password, PostCode = postCode, TimeZoneCode = timeZone, Title = title, Town = town, Username = username, BonusCode = bonusCode, Referrer = referrer, OddsDisplay = odds, EmailComPref = notifyViaEmail, InPlatformComPref = notifyViaPlatform, NotificationComPref = notify, TextMessageComPref = notifyViaSMS }; try { IRestResponse response = await SubmitPostAsync(URL_CUSTOMER_REGISTER, "", customer, authorization, tenantUid); return(await AssertResponseContentAsync <CustomerRegisterResponseContent>(response)); } catch (Exception ex) { return(new CustomerRegisterResponseContent { Exception = ex }); } }