/// <summary> /// database connection for Registrion /// </summary> /// <param name="data"> store the Complete Employee information</param> /// <returns></returns> public async Task <bool> UserRegister(Usermodel data) { try { SqlConnection connection = DatabaseConnection(); //password encrption string Password = EncryptedPassword.EncodePasswordToBase64(data.Password); //for store procedure and connection to database SqlCommand command = StoreProcedureConnection("spParkingUserRegister", connection); command.Parameters.AddWithValue("@FirstName", data.FirstName); command.Parameters.AddWithValue("@LastName", data.LastName); command.Parameters.AddWithValue("@EmailID", data.EmailID); command.Parameters.AddWithValue("@Password", Password); command.Parameters.AddWithValue("@UserRole", data.UserRole); command.Parameters.AddWithValue("@CreateDate", data.CreateDate); connection.Open(); int Response = await command.ExecuteNonQueryAsync(); connection.Close(); if (Response != 0) { return(true); } else { return(false); } } catch (Exception e) { throw new Exception(e.Message); } }
public int resetRoom(int roomNo, int floorNo) { Usermodel roomsModel = new Usermodel(roomNo, floorNo); HttpResponseMessage response = GlobalVariables.WebApiClient.PutAsJsonAsync("room/removeUser/" + roomNo, roomsModel).Result; return(Convert.ToInt32(response.StatusCode)); }
public async Task <IActionResult> UserRegister([FromBody] Usermodel Info) { try { bool data = await BusinessLayer.UserRegister(Info); //if data is not equal to null then Registration sucessful if (!data.Equals(null)) { var Success = "True"; var Message = "Registration Successfull"; return(this.Ok(new { Success, Message, Info })); } else //Registration Fail { var Success = "False"; var Message = "Registration Failed"; return(this.BadRequest(new { Success, Message, data = Info })); } } catch (Exception e) { return(BadRequest(new { error = e.Message })); } }
/// <summary> /// create new user /// </summary> /// <param name="usm"></param> /// <returns></returns> public static int CreateUser(Usermodel usm) { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateNewCommand(); // set the stored procedure name //comm.CommandText = "insert into users values(2,'firstname','lastnmae','address','*****@*****.**','sjflsj',GETDATE(),0)"; comm.CommandText = "insert into users values(@firstname,@lastname,@address,@email,@password,@datetime,0)"; DbParameter param1 = comm.CreateParameter(); param1.ParameterName = "@firstname"; param1.DbType = DbType.String; param1.Value = usm.first_name; DbParameter param2 = comm.CreateParameter(); param2.ParameterName = "@lastname"; param2.DbType = DbType.String; param2.Value = usm.last_name; DbParameter param3 = comm.CreateParameter(); param3.ParameterName = "@address"; param3.DbType = DbType.String; param3.Value = usm.Address; DbParameter param4 = comm.CreateParameter(); param4.ParameterName = "@email"; param4.DbType = DbType.String; param4.Value = usm.Email; DbParameter param5 = comm.CreateParameter(); param5.ParameterName = "@password"; param5.DbType = DbType.String; param5.Value = usm.Password; DbParameter param6 = comm.CreateParameter(); param6.ParameterName = "@datetime"; param6.DbType = DbType.DateTime; param6.Value = DateTime.Now; comm.Parameters.Add(param1); comm.Parameters.Add(param2); comm.Parameters.Add(param3); comm.Parameters.Add(param4); comm.Parameters.Add(param5); comm.Parameters.Add(param6); return(GenericDataAccess.ExecuteNonQuery(comm)); }
public static List <Usermodel> ValidateUser(string userName, string password) { var list = new List <Usermodel>(); Usermodel user = new Usermodel(); user.UserName = "******"; user.Password = "******"; list.Add(user); return(list); }
public override int GetHashCode() { int hash = 1; if (usermodel_ != null) { hash ^= Usermodel.GetHashCode(); } hash ^= uphone_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public List <DetailPerson> GetDetails() { List <PersonModel> personList = _person.Find(person => true).ToList(); List <Usermodel> usersList = new List <Usermodel>(); List <PossitionModel> possitionsList = new List <PossitionModel>(); List <DetailPerson> detailList = new List <DetailPerson>(); foreach (PersonModel element in personList) { Usermodel um = _users.Find <Usermodel>(user => user.id == element.User_id).FirstOrDefault(); PossitionModel pm = _possitionss.Find <PossitionModel>(possition => possition.Id == element.Possition_id).FirstOrDefault(); detailList.Add(new DetailPerson(element.Id, element.FirstName, element.LastName, element.Age, pm.name, pm.income, pm.freedays, um.login)); } return(detailList); }
public void MergeFrom(UserDetail other) { if (other == null) { return; } if (other.usermodel_ != null) { if (usermodel_ == null) { Usermodel = new global::GrpcDemo.Protos.UserModel(); } Usermodel.MergeFrom(other.Usermodel); } uphone_.Add(other.uphone_); _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public async Task <IActionResult> Register([FromBody] Usermodel username) { try { var login = await ApplicationUserRepository.CreateAsync(username); return(Ok(new LoginView { IsSuccess = login.identityResult.Succeeded, User = new ApplicationUser { Id = login.userId }, Role = login.role, Token = login.Token.Token, Errors = login.identityResult.Errors.Select(error => error.Description).ToList() })); } catch (Exception) { throw; } }
protected void LoginButton_Click(object sender, EventArgs e) { TextBox usernameTextBox = UserName; TextBox passwordTextBox = Password; Usermodel model = UserBLO.getUserInfoByUseranme(usernameTextBox.Text, passwordTextBox.Text); if (model != null) // redirect { Session["userid"] = model.user_id.ToString(); Session["username"] = model.first_name; Session["useremail"] = model.Email; Session["useraddress"] = model.Address; Session["role_type"] = model.role_type; Response.Redirect("Default.aspx"); } else { //alert } }
protected void btnRegister_Click(object sender, EventArgs e) { Usermodel mdl = new Usermodel(); mdl.first_name = txtFName.Text; mdl.last_name = txtLName.Text; mdl.Password = txtPassword.Text; mdl.Email = txtEmail.Text; mdl.Address = txtAddress.Text; int result = UserBLO.CreateUser(mdl); if (result == 1) { if (!ClientScript.IsStartupScriptRegistered("alert")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alertMe();", true); } } }
/// <summary> /// API for Registrion /// </summary> /// <param name="data"> store the Complete User information</param> /// <returns></returns> public async Task <bool> UserRegister(Usermodel data) { try { var Result = await _UserRepository.UserRegister(data); //if result is not equal null then return true if (!Result.Equals(null)) { return(true); } else { return(false); } } catch (Exception e) { throw new Exception(e.Message); } }
public async Task <IActionResult> Index(Administrador model, string Usu, string pass) { Usermodel Admin = new Usermodel(); var ValidaLogin = Admin.LoginAdmin(Usu, pass); if (ModelState.IsValid) { if (ValidaLogin == true) { return(View("EntradaAdmin")); } else { ViewBag.mess = "El Usuario o La ContraseƱa incorrecta"; return(View(model)); } } else { return(View(model)); } }
public IActionResult Index(Ciudadanos model, string cedu) { Usermodel User = new Usermodel(); var ValidaLogin = User.LoginUser(cedu); if (ModelState.IsValid) { if (ValidaLogin == true) { return(View("Entrada")); } else { ViewBag.mess = "El usuario o la contraseƱa es incorrecta"; return(View(model)); } } else { return(View(model)); } }
/// <summary> /// get user by user name /// </summary> /// <param name="userName"></param> /// <returns></returns> public static Usermodel getUserInfoByUseranme(string userName, string password) { Usermodel model = new Usermodel(); DbCommand comm = GenericDataAccess.CreateNewCommand(); comm.CommandText = "select user_id,first_name,last_name,address,email,password,role_type from users where email=@email"; DbParameter param1 = comm.CreateParameter(); param1.ParameterName = "@email"; param1.DbType = DbType.String; param1.Value = userName; comm.Parameters.Add(param1); DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); if (table.Rows.Count > 0) { // get the first table row DataRow dr = table.Rows[0]; model.user_id = Int32.Parse(dr["user_id"].ToString()); model.first_name = dr["first_name"].ToString(); model.last_name = dr["last_name"].ToString(); model.Address = dr["address"].ToString(); model.Email = dr["email"].ToString(); model.Password = dr["password"].ToString(); model.role_type = Int32.Parse(dr["role_type"].ToString()); } if (password == model.Password) { return(model); } else { return(null); } }
public Usermodel Create(Usermodel book) { _books.InsertOne(book); return(book); }
public void Remove(Usermodel bookIn) { _books.DeleteOne(book => book.id == bookIn.id); }
public static int CreateUser(Usermodel usm) { return(UserDAO.CreateUser(usm)); }
public async Task <(IdentityResult identityResult, string role, string userId, UserToken Token)> CreateAsync(Usermodel user) { try { var _user = new ApplicationUser { SecurityStamp = Guid.NewGuid().ToString(), UserName = user.Email, Email = user.Email, Fullname = user.Fullname, Province = user.Province, FullAddress = user.FullAddress, PhoneNumber = user.PhoneNumber }; //check roles if (!await RoleManager.RoleExistsAsync(user.Role)) { var identityRole = new IdentityRole(); identityRole.Name = user.Role; var results = await RoleManager.CreateAsync(identityRole); var token = BuildToken(_user.Email); return(results, user.Role, _user.Id, token); } var result = await UserManager.CreateAsync(_user, user.Password); if (result.Succeeded) { var addRole = await UserManager.AddToRoleAsync(_user, user.Role); var _token = BuildToken(_user.Email); return(result, user.Role, _user.Id, _token); } else { return(result, user.Role, _user.Id, null); } } catch (Exception) { throw; } }
public void Update(string id, Usermodel bookIn) { _books.ReplaceOne(book => book.id == id, bookIn); }