public ActionResult SuperAdminCreateCompany() { var sd = new CompanyRegisterModel(); sd.companys = orgService.GetAvaiOrganizations(); return(View(sd)); }
public ActionResult CreateRequest(CompanyRegisterModel model) { if (!ModelState.IsValid) { return(JsonValidationError()); } if (!string.IsNullOrEmpty(model.Password)) { if (!Regex.IsMatch(model.Password, SiteUtils.GetPasswordRegex())) { ModelState.AddModelError("Password", "Password does not meet policy!"); return(JsonValidationError()); } } model.Mobile = SiteUtils.GenerateEncodedString(model.Mobile); model.Telephone = SiteUtils.GenerateEncodedString(model.Telephone); var user = new CustomerModel { Email = Sanitizer.GetSafeHtmlFragment(model.Email), FirstName = Sanitizer.GetSafeHtmlFragment(model.FirstName), LastName = Sanitizer.GetSafeHtmlFragment(model.LastName), Mobile = Sanitizer.GetSafeHtmlFragment(model.Mobile), PostCode = Sanitizer.GetSafeHtmlFragment(model.PostCode), Telephone = Sanitizer.GetSafeHtmlFragment(model.Telephone), Title = Sanitizer.GetSafeHtmlFragment(model.Title), BusinessType = Sanitizer.GetSafeHtmlFragment(model.BusinessType), CompanyName = Sanitizer.GetSafeHtmlFragment(model.CompanyName), RegisteredNumber = Sanitizer.GetSafeHtmlFragment(model.RegisteredNumber), Password = Sanitizer.GetSafeHtmlFragment(model.Password), IsRegistered = true, Address = new CompanyAddress { Address1 = Sanitizer.GetSafeHtmlFragment(model.Address1), Address2 = Sanitizer.GetSafeHtmlFragment(model.Address2), City = Sanitizer.GetSafeHtmlFragment(model.City), State = Sanitizer.GetSafeHtmlFragment(model.State), Country = Sanitizer.GetSafeHtmlFragment(model.Country), PostCode = Sanitizer.GetSafeHtmlFragment(model.PostCode) }, }; user.Mobile = SiteUtils.GenerateDecodeString(user.Mobile); user.Telephone = SiteUtils.GenerateDecodeString(user.Telephone); var result = _customerRepository.Register(user); if (result.Result.IsValid) { return(JsonSuccess(result.Result, JsonRequestBehavior.AllowGet)); } else { ModelState.AddModelError("Error", "Registration Request failed!"); return(JsonValidationError()); } }
//company register public ActionResult Register() { var sd = new CompanyRegisterModel(); sd.WhichToShow = "user"; OrganizationService orService = new OrganizationService(); sd.companys = orService.GetAvaiOrganizations(); return(View(sd)); }
public async Task <IActionResult> Register([FromBody] CompanyRegisterModel model) { using (var client = clientHelper.GetServiceSecuredClient(User)) { var resp = await client.PostAsync(this.routeTable.GetRoute(SvcRouteTable.CompanyCreate), new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")); if (!resp.IsSuccessStatusCode) { return(new StatusCodeResult((int)resp.StatusCode)); } return(Ok()); } }
public async Task <IActionResult> CompanyRegister(CompanyRegisterModel model) { if (ModelState.IsValid) { var name = model.CompanyEmail; var pass = model.CompanyPassword; var confirmPass = model.CompanyConfirmPassword; string hashed_password = SecurePasswordHasherHelper.Hash(pass); connect = new ConnDatabase(); connect.sqlQuery("INSERT INTO Company (CompanyEmail, CompanyPassword) Values('" + name + "', '" + hashed_password + "')"); connect.NonExecute(); } return(View(model)); }
/// <summary> /// 企业信息页面 /// </summary> /// <returns></returns> public ActionResult EnterpriseInfo() { if (CurrentCustomer.CustomerType != Core.Domain.Customers.CustomerType.Admin) { return(new HttpUnauthorizedResult()); } var organization = organizationService.Get(s => s.Id == CurrentCustomer.OrganizationId); var companyRegisterModel = new CompanyRegisterModel() { CompanyID = organization.OrganizationNumber.ToString(), CompanyType = organization.OrganizationType.GetDescription(), CompanyName = organization.Name, Address = organization.OrganizationAddress, ZipCode = organization.ZipCode, CompanyPhone = organization.OrganizationTelephone, BusinessLicence = organization.BusinessLicence, UploadLicenceUri = organization.BusinessLicensePicUri }; return(View(companyRegisterModel)); }
public ActionResult SuperAdminCreateCompany(CompanyRegisterModel companyRM) { OrganizationService orService = new OrganizationService(); companyRM.companys = orService.GetAvaiOrganizations(); companyRM.WhichToShow = "company"; string uploadLicenceUri = ""; if (companyRM.CompanyID == "" || companyRM.CompanyID == null) { companyRM.CompanyIdError = "企业组织机构代码应为15位数字"; return(View(companyRM)); } if (companyRM.ZipCode != null && companyRM.ZipCode != null) { Regex zipcodeReg = new Regex("^\\d{6}$"); if ((!zipcodeReg.IsMatch(companyRM.ZipCode))) { companyRM.ZipCodeError = "邮编应为6位数字"; return(View(companyRM)); } } else { companyRM.ZipCodeError = "邮编应为6位数字"; return(View(companyRM)); } //Regex companyPhoneReg = new Regex("^[-\\d]{7-20}$"); //if ((!companyPhoneReg.IsMatch(companyRM.CompanyPhone))) //{ // companyRM.CompanyPhoneError = "公司电话格式有误"; // return View(companyRM); //} //验证用户名是否存在 if (companyRM.Account != null && companyRM.Account != "") { if (RegisterBusinessLayer.CheckAccountExist(companyRM.Account)) { companyRM.AccountError = "已存在的用户名,请使用其他的用户名"; return(View(companyRM)); } } else { companyRM.AccountError = "账号不能为空"; return(View(companyRM)); } //验证公司名是否存在 if (companyRM.CompanyName != null && companyRM.CompanyName != "") { if (RegisterBusinessLayer.CheckCompanyExist(companyRM.CompanyName)) { companyRM.CompanyNameError = "已存在的公司名,请使用其他的公司名"; return(View(companyRM)); } } else { companyRM.CompanyNameError = "公司名称不能为空"; return(View(companyRM)); } //验证邮箱格式 if (companyRM.ApplyEmail != null && companyRM.ApplyEmail != "") { string emailStr = @"^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,5})+$"; //邮箱正则表达式对象 Regex emailReg = new Regex(emailStr); if (!emailReg.IsMatch(companyRM.ApplyEmail)) { companyRM.EmailError = "请填写正确的邮箱格式"; return(View(companyRM)); } } else { companyRM.EmailError = "请填写正确的邮箱格式"; return(View(companyRM)); } if (companyRM.ApplyPhone != null && companyRM.ApplyPhone != "") { Regex mobileReg = new Regex("^[0-9]{11,11}$"); if (!mobileReg.IsMatch(companyRM.ApplyPhone)) { companyRM.MobileError = "手机号码应为11位数字"; return(View(companyRM)); } } else { companyRM.MobileError = "手机号码应为11位数字"; return(View(companyRM)); } /* * var file = Request.Files[0]; * if (file != null && file.ContentLength > 0) * { * * * //文件名的key和value * string savePath = Server.MapPath("~/upload/BusinessLicencePicture"); * if (!System.IO.Directory.Exists(savePath)) * { * System.IO.Directory.CreateDirectory(savePath); * } * Guid addToTheEnd = new Guid(); * string filepath = savePath + "\\" + file.FileName + addToTheEnd; * file.SaveAs(filepath); * uploadLicenceUri = filepath; * * } * else * { * //上传失败返回到注册页面 * return View(companyRM); * * //InfoAllRight = false; * //backMessage = backMessage + "上传图片有误/n"; * } */ //uploadLicenceUri = "asd/asd/asd"; if (companyRM.UploadLicenceUri != null && companyRM.UploadLicenceUri != "") { uploadLicenceUri = companyRM.UploadLicenceUri; } else { companyRM.UriError = "图片不能为空!"; return(View(companyRM)); } //保存 Organization org = new Organization(); org.BusinessLicence = companyRM.BusinessLicence; //get uri by last step org.BusinessLicensePicUri = uploadLicenceUri; org.ContacterName = companyRM.ApplyName; org.ContacterPhone = companyRM.ApplyPhone; org.Name = companyRM.CompanyName; org.OrganizationAddress = companyRM.Address; org.OrganizationNumber = companyRM.CompanyID; org.OrganizationTelephone = companyRM.CompanyPhone; org.OrganizationStatus = OrganizationStatus.Available; OrganizationType companyType; string comtype = companyRM.CompanyType; switch (comtype) { case "设计公司": companyType = OrganizationType.DesignCompany; break; case "建设公司": companyType = OrganizationType.BuildingCompany; break; case "审查机构": companyType = OrganizationType.Censorship; break; default: companyType = OrganizationType.DesignCompany; break; } org.OrganizationType = companyType; org.ProposerEmail = companyRM.ApplyEmail; org.ProposerName = companyRM.ApplyName; org.ProposerPhone = companyRM.ApplyPhone; org.ZipCode = companyRM.ZipCode; //new OrganizationService(); Customer cus = new Customer(); DateTime localDate = DateTime.Now; cus.CreateTime = localDate; cus.LastVisitTime = localDate; //need to add cus.EmployeeId = "P0802"; System.Guid guid = System.Guid.NewGuid(); cus.CustomerGuid = guid; cus.CustomerStatus = CustomerStatus.Available; cus.CustomerType = CustomerType.Admin; cus.Email = companyRM.ApplyEmail; cus.Mobile = companyRM.ApplyPhone; //need to add cus.Telephone = companyRM.ApplyPhone; //need to add cus.Department = "liuliu"; cus.Name = companyRM.ApplyName; //cus.Organization = org; cus.OrganizationId = org.Id; cus.Password = companyRM.Password; cus.UserAccount = companyRM.Account; bool isSuccess = new OrganizationService().InsertOrganizationAndUser(org, cus); //new CustomerService().Insert(cus); //设置登陆状态并跳转到对应功能页 // LoginCheck.PasswordSignIn(companyRM.Account, companyRM.Password, this.SetCustomerCookie); return(RedirectToAction("SuperAdminchecklist")); }
public ActionResult SuperAdminCreateUser(CompanyRegisterModel companyRM) { OrganizationService orService = new OrganizationService(); companyRM.companys = orService.GetAvaiOrganizations(); companyRM.WhichToShow = "user"; if (companyRM.UserAccount != "" && companyRM.UserAccount != null) { //验证用户名是否存在 if (RegisterBusinessLayer.CheckAccountExist(companyRM.UserAccount)) { companyRM.AccountError = "已存在的用户名,请使用其他的用户名"; return(View("Register", companyRM)); } } else { companyRM.AccountError = "用户名不能为空"; return(View("Register", companyRM)); } if (companyRM.UserEmail != "" && companyRM.UserEmail != null) { //验证邮箱格式 string emailStr = @"^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,5})+$"; //邮箱正则表达式对象 Regex emailReg = new Regex(emailStr); if (!emailReg.IsMatch(companyRM.UserEmail)) { companyRM.EmailError = "输入的邮件格式有误"; return(View("Register", companyRM)); } } else { companyRM.EmailError = "邮箱不能为空"; return(View("Register", companyRM)); } if (companyRM.UserMobile != "" && companyRM.UserMobile != null) { Regex mobileReg = new Regex("^[0-9]{11,11}$"); if (!mobileReg.IsMatch(companyRM.UserMobile)) { companyRM.MobileError = "手机格式有误"; return(View("Register", companyRM)); } } else { companyRM.MobileError = "手机号不能为空"; return(View("Register", companyRM)); } string userCompanyId = companyRM.UserCompanyId; int orgId; if (userCompanyId != null && userCompanyId != "") { orgId = Convert.ToInt32(userCompanyId); } else { companyRM.CompanyIdAndNameError = "公司名不能为空"; return(View("Register", companyRM)); } //保存 //OrganizationType companyType; //string comtype = companyRM.CompanyType; //switch (comtype) //{ // case "设计公司": companyType = OrganizationType.DesignCompany; break; // case "建设公司": companyType = OrganizationType.BuildingCompany; break; // case "审查机构": companyType = OrganizationType.Censorship; break; // default: companyType = OrganizationType.DesignCompany; break; //} //new OrganizationService(); Customer cus = new Customer(); DateTime localDate = DateTime.Now; cus.CreateTime = localDate; cus.LastVisitTime = localDate; //need to add cus.EmployeeId = "P0802"; System.Guid guid = System.Guid.NewGuid(); cus.CustomerGuid = guid; cus.CustomerStatus = CustomerStatus.Available; cus.CustomerType = CustomerType.User; cus.Email = companyRM.UserEmail; cus.Mobile = companyRM.UserMobile; //need to add cus.Telephone = companyRM.UserMobile; //need to add cus.Department = "liuliu"; cus.Name = companyRM.UserName; cus.OrganizationId = orgId; //cus.Organization = orService.GetOrgById(orgId); cus.Password = companyRM.UserPassword; cus.UserAccount = companyRM.UserAccount; new CustomerService().Insert(cus); //设置登陆状态并跳转到对应功能页 return(RedirectToAction("SuperAdminchecklist")); }
public async Task <IActionResult> RegisterCompany([FromBody] CompanyRegisterModel model) { var userExists = await _userManager.FindByNameAsync(model.UserName); if (userExists != null) { if (!userExists.IsDeleted) { return(StatusCode(StatusCodes.Status500InternalServerError, new { Success = false, Message = "User already exists!" })); } else { return(BadRequest(new { Success = false, Message = "UserName not allowed" })); } } if (string.IsNullOrWhiteSpace(model.UserName)) { return(BadRequest(new { Success = false, Message = "UserName is required" })); } if (string.IsNullOrWhiteSpace(model.Password)) { return(BadRequest(new { Success = false, Message = "Password is required" })); } if (string.IsNullOrWhiteSpace(model.Name)) { return(BadRequest(new { Success = false, Message = "Name is required" })); } if (string.IsNullOrWhiteSpace(model.PhoneNumber)) { return(BadRequest(new { Success = false, Message = "Phone number is required" })); } /*if (new PhoneAttribute().IsValid(model.PhoneNumber)) * return BadRequest(new { Success = false, Message = "Phone number invalid" }); */ if (string.IsNullOrWhiteSpace(model.Address)) { return(BadRequest(new { Success = false, Message = "Address is required" })); } User user = new User() { UserName = model.UserName, SecurityStamp = Guid.NewGuid().ToString(), Company = new Company { Name = model.Name, PhoneNumber = model.PhoneNumber, Address = model.Address } }; var result = await _userManager.CreateAsync(user, model.Password); if (!result.Succeeded) { return(StatusCode(StatusCodes.Status500InternalServerError, new { Success = false, Message = "User creation failed! Please check user details and try again." })); } if (!await _roleManager.RoleExistsAsync(RoleType.Admin)) { await _roleManager.CreateAsync(new Role(RoleType.Admin)); } if (!await _roleManager.RoleExistsAsync(RoleType.Candidate)) { await _roleManager.CreateAsync(new Role(RoleType.Candidate)); } if (!await _roleManager.RoleExistsAsync(RoleType.Company)) { await _roleManager.CreateAsync(new Role(RoleType.Company)); } await _userManager.AddToRoleAsync(user, RoleType.Company); return(Ok(new { Success = true, Message = "User created successfully!" })); }
public async Task <IActionResult> RegisterCompany([FromBody] CompanyRegisterModel model) { var contactUser = new User { DateAdded = DateTime.UtcNow, UserName = model.Contact_Email, Email = model.Contact_Email, FirstName = model.Contact_Name, LastName = model.Contact_Surname, PhoneNumber = model.Contact_Number, }; var companyUser = new User { DateAdded = DateTime.UtcNow, UserName = model.Company_Email, Email = model.Company_Email, FirstName = model.Company_Name, LastName = model.Company_Surname, PhoneNumber = model.Company_Number, }; var contactResult = await _userManager.CreateAsync(contactUser, model.Password); var companyResult = await _userManager.CreateAsync(companyUser, model.Password); if (contactResult.Succeeded && companyResult.Succeeded) { var role = Role.Company; await EnsureRoleExists(role); await _userManager.AddToRoleAsync(contactUser, role); await _userManager.AddToRoleAsync(companyUser, role); var company = new Company { ContactAccountGuid = contactUser.Id, CompanyAccountGuid = companyUser.Id, Name = model.CompanyName, EmployeeCount = model.EmployeeCount, ITEmployeeCount = model.ITEmployeeCount, SupportingITEmployees = model.SupportingITEmployees, Latitude1 = model.Lat1, Longitude1 = model.Lng1, Latitude2 = model.Lat2, Longitude2 = model.Lng2, ContactTitle = model.Contact_Title, CompanyTitle = model.Company_Title }; await _userService.CreateCompany(company); await _userService.AssignCompany(contactUser, company.Id); await _userService.AssignCompany(companyUser, company.Id); var verifToken = await _userManager.GenerateEmailConfirmationTokenAsync(contactUser); var client = new SendGridClient(Environment.GetEnvironmentVariable("SG_API_KEY")); await client.SendEmailAsync(MailHelper.CreateSingleEmail( new EmailAddress("*****@*****.**", "PXL Stageplatform"), new EmailAddress(contactUser.Email), "Verifiëer uw emailadres", $"Beste gebruiker, verfiëer uw emailadres door op de volgende link te klikken: http://localhost:4200/#/verify/?t={HttpUtility.UrlEncode(verifToken)}&u={contactUser.Id}", $"Beste gebruiker,<br><br>Verfiëer uw emailadres door op de volgende link te klikken: <a href=\"http://*****:*****@gmail.com", "PXL Stageplatform"), new EmailAddress(companyUser.Email), "Verifiëer uw emailadres", $"Beste gebruiker, verfiëer uw emailadres door op de volgende link te klikken: http://localhost:4200/#/verify/?t={HttpUtility.UrlEncode(verifToken)}&u={companyUser.Id}", $"Beste gebruiker,<br><br>Verfiëer uw emailadres door op de volgende link te klikken: <a href=\"http://localhost:4200/#/verify?t={HttpUtility.UrlEncode(verifToken)}&u={companyUser.Id}\">http://localhost:4200/#/verify?t={HttpUtility.UrlEncode(verifToken)}&u={companyUser.Id}</a>") ); return(Ok()); } foreach (var error in contactResult.Errors) { ModelState.AddModelError(error.Code, error.Description); } return(BadRequest(ModelState)); }
public IHttpActionResult Register(CompanyRegisterModel companyRegisterModel) { string error_message = "Register錯誤,請至伺服器log查詢錯誤訊息"; //格式 if (!ModelState.IsValid) { return(Ok(new { result = "格式錯誤" })); } JArray jArray = Utility.getjson("https://paim.coa.gov.tw/api/BusinessList?IsActive=1"); bool PBL_flag = false;//證書號是否有在名單上 foreach (var item in jArray) { if (item["PBLicense"].ToString() == companyRegisterModel.pblicense) { if (Convert.ToDateTime(item["EffectiveDate"]) == Convert.ToDateTime(companyRegisterModel.effectivedate)) { PBL_flag = true; } break; } } //證書號 if (!PBL_flag) { return(Ok(new { result = "證書號不在合法寵物業者名單上" })); } try { //信箱重複 if (companyExists(companyRegisterModel.email)) { return(Ok(new { result = "信箱重複" })); } //正常流程 //using (var transaction1 = db.Database.BeginTransaction()) // { // string today = DateTime.Now.ToString("yyyyMMdd"); //Company getseq = db.Company.Where(x => x.companyseq.Contains(today)).OrderByDescending(x => x.companyseq).FirstOrDefault(); // int seq = getseq is null ? 0000 : Convert.ToInt32((getseq.companyseq.Substring(9, 4)));//流水號 Company company = new Company(); //company.companyseq = "C" + DateTime.Now.ToString("yyyyMMdd") + (seq + 1).ToString("0000"); company.companyname = companyRegisterModel.companyname; company.companybrand = companyRegisterModel.companybrand; company.phone = companyRegisterModel.phone; company.email = companyRegisterModel.email; company.pwdsalt = Utility.CreateSalt();; company.pwd = Utility.GenerateHashWithSalt(companyRegisterModel.pwd, company.pwdsalt); company.country = companyRegisterModel.country; company.area = companyRegisterModel.area; company.address = companyRegisterModel.address; company.pblicense = companyRegisterModel.pblicense; company.effectivedate = companyRegisterModel.effectivedate; company.avatar = companyRegisterModel.avatar; company.state = true; //狀態1 通過 company.del_flag = "N"; db.Company.Add(company); db.SaveChanges(); //transaction1.Commit(); // } return(Ok(new { result = "註冊成功" })); } catch (Exception ex) { Utility.log("廠商註冊", ex.ToString()); return(Ok(new { result = error_message })); } }
public ActionResult AdminCreateUser() { CompanyRegisterModel crModel = new CompanyRegisterModel(); return(View(crModel)); }