public IHttpActionResult post_register([FromBody] registerModel model) { if (ModelState.IsValid) { // model.password = password_hash.hash(model.password); //return Json( new { model, // passwordlength = model.password.Length, //verify = password_hash.Verify("123456",model.password)} //); / ใช้เทียบรหัสผ่าน/ try { model.password = password_hash.hash(model.password); this.account.Register(model); return(Ok("Succesful")); } catch (Exception ex) { ModelState.AddModelError("Exception", ex.Message); } // return Json(model); } //return Json(new //{ ModelStateError = registerModel.GerErrorModelState(ModelState) }); // (registerModel.model(ModelState)); return(BadRequest(ModelState.GerErrorModelState())); }
public IActionResult Register([FromBody] registerModel value) { if (value == null) { return(BadRequest("Recieved a Bad request")); } return(Ok(value)); }
public IActionResult Test(registerModel model) { if (string.IsNullOrEmpty(model.Name)) { return(BadRequest("İsim Boş Bırakılamaz")); } if (string.IsNullOrEmpty(model.Surname)) { return(BadRequest("Soyisim Boş Bırakılamaz")); } return(Ok()); }
UserModel IUserManager.RegisterUser(registerModel model) { Passhash = Crypto.Hash(model.Password); User data = new User(); data.FirstName = model.Name; //data. = model.PhoneNo; data.Password = Passhash; //data.Email = "*****@*****.**"; data.UserType = 1; data.CreatedAt = DateTime.Now; Context.Users.Add(data); Context.SaveChanges(); return(new UserModel(data)); }
public ActionResult Index(registerModel model) { if (ModelState.IsValid) { user u = new user(); u.email = model.email; u.hinhanh = null; u.maquyen = 1; u.password = model.password; u.ttdn = 0; u.tentk = model.tentk; //u.id = (long)kh.makh; khachhang kh = new khachhang(); kh.email = model.email; kh.gioitinh = model.gioitinh; kh.hoten = model.hoten; kh.matk = u.id; kh.diachi = model.diachi; kh.sodt = model.sodt; kh.ghichu = null; //kh.matk = u.id; //kh.makh = null; if (new RegisterDao().DangKi(u, kh)) { ViewBag.success = "Đăng kí thành công"; //return RedirectToAction("Client/Home/Index"); model = new registerModel(); } else { ViewBag.fail = "Đăng kí thất bại"; ModelState.AddModelError("", "Email đã tồn tại"); return(RedirectToAction("Index")); } } return(View()); }
public IActionResult Register([FromBody] registerModel model) { if (string.IsNullOrEmpty(model.Name)) { return(BadRequest("İsim Boş Bırakılamaz")); } var message = "Kayıt İşlemi Başarılı"; var test = _db.Set <Account>().FirstOrDefault(x => x.Email == model.Email); if (test != null) { if (test.Email == model.Email) { return(BadRequest("Aynı Mail Adresi Sistemde Bulunmaktadır. Farklı bir mail adresi ile kayıt olmayı deneyiniz")); } } if (ModelState.IsValid) { var user = new Account { Id = Guid.NewGuid(), Name = model.Name, Surname = model.Surname, Age = model.Age, Email = model.Email, isActive = true, }; _db.Entry(user).State = Microsoft.EntityFrameworkCore.EntityState.Added; CreatePassword(user.Id, model.Password, model.ConfirPassword); _db.SaveChanges(); return(Json(message)); } return(BadRequest("Kayıt Yapılamadı!")); }
//ลงทะเบียน public void Register(registerModel model) { try { this.database.members.Add(new member { firstname = model.firstName, lastname = model.lastname, email = model.email, password = model.password, position = "", image = null, role = Roleaccount.Member, created = DateTime.Now, updated = DateTime.Now } ); this.database.SaveChanges(); //this.datablase.sqlqurey(""); /*คำสั่ง sql */ } catch (Exception ex) { throw ex.GetError(); } }
public IActionResult Register([FromBody] registerModel model) { string Defaultrole; if (string.IsNullOrEmpty(model.Name)) { return(BadRequest("İsim Boş Bırakılamaz")); } if (string.IsNullOrEmpty(model.Surname)) { return(BadRequest("Soyİsim Boş Bırakılamaz")); } if (string.IsNullOrEmpty(model.Email)) { return(BadRequest("Email Boş Bırakılamaz")); } if (string.IsNullOrEmpty(model.Password)) { return(BadRequest("Parola Boş Bırakılamaz")); } if (string.IsNullOrEmpty(model.ConfirPassword)) { return(BadRequest("Parola Tekrar Boş Bırakılamaz")); } if (model.Password != model.ConfirPassword) { return(BadRequest("Parola Eşleşmedi!")); } if (!model.isActive) { return(BadRequest("Sözleşmeyi Onaylamanız Gerekmektedir.")); } var message = "Kayıt İşlemi Başarılı"; var test = _db.Set <Account>().FirstOrDefault(x => x.Email == model.Email); if (test != null) { if (test.Email == model.Email) { return(BadRequest("Aynı Mail Adresi Sistemde Bulunmaktadır. Farklı bir mail adresi ile kayıt olmayı deneyiniz")); } } if (model.role == null) { Defaultrole = "User"; } else { Defaultrole = model.role; } if (ModelState.IsValid) { var user = new Account { Id = Guid.NewGuid(), Name = model.Name, Surname = model.Surname.ToUpperInvariant(), Age = model.Age, Email = model.Email, isActive = model.isActive, Role = Defaultrole }; _db.Entry(user).State = Microsoft.EntityFrameworkCore.EntityState.Added; CreatePassword(user.Id, model.Password, model.ConfirPassword); _db.SaveChanges(); return(Json(message)); //if (model.Password == model.ConfirPassword) //{ // model.isActive = true; // _db.Entry(model).State = Microsoft.EntityFrameworkCore.EntityState.Added; // _db.SaveChanges(); // return Json(message); //} } return(BadRequest()); }