public Constants.ACTION_STATUS SelectLogin(string username, string password) { Constants.ACTION_STATUS isLogin = Constants.ACTION_STATUS.UNKNOWN; User user = new User(); user.UserName = username; user.Password = password; user = employeeBroker.GetUser(user); // get user object // if user is null means username and password is incorrect if (user != null) { Employee employee = new Employee(); employee.User = user; employee = employeeBroker.GetEmployee(employee); Util.SetEmployee(employee); // put employee object to session for validating user later Util.PutSession("Uname", employee.Name); isLogin = Constants.ACTION_STATUS.SUCCESS; } else { isLogin = Constants.ACTION_STATUS.FAIL; } return isLogin; }
public Employee(int id, User userId, Role roleId, Department departmentId, string name, int designation, string email, DateTime createdDate, Employee createdBy, int status) { this.Id = id; this.User = userId; this.Role = roleId; this.Department = departmentId; this.Name = name; this.Designation = designation; this.Email = email; this.CreatedDate = createdDate; this.CreatedBy = createdBy; this.Status = status; }
/// <summary> /// Create a new User object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="userName">Initial value of the UserName property.</param> /// <param name="password">Initial value of the Password property.</param> /// <param name="createdDate">Initial value of the CreatedDate property.</param> /// <param name="status">Initial value of the Status property.</param> public static User CreateUser(global::System.Int32 id, global::System.String userName, global::System.String password, global::System.DateTime createdDate, global::System.Int32 status) { User user = new User(); user.Id = id; user.UserName = userName; user.Password = password; user.CreatedDate = createdDate; user.Status = status; return user; }
/// <summary> /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }
/// <summary> /// Logically delete to the status of user table /// </summary> /// <param name="user"></param> /// <returns> /// Returns DB_STATUS /// </returns> public Constants.DB_STATUS Delete(User user) { Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN; try { userObj = inventory.Users.Where(uObj => uObj.Id == user.Id).First(); if (userObj != null) { userObj.Status = 2; inventory.SaveChanges(); status = Constants.DB_STATUS.SUCCESSFULL; } } catch (Exception e) { status = Constants.DB_STATUS.FAILED; } return status; }
/// <summary> /// Update the user data to the user table /// </summary> /// <param name="user"></param> /// <returns> /// Returns DB_STATUS /// </returns> public Constants.DB_STATUS Update(User user) { Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN; try { userObj = inventory.Users.Where(uObj => uObj.Id == user.Id).First(); if (userObj != null) { userObj.Id = user.Id; userObj.UserName = user.UserName; userObj.Password = user.Password; userObj.CreatedDate = user.CreatedDate; inventory.SaveChanges(); status = Constants.DB_STATUS.SUCCESSFULL; } } catch (Exception e) { status = Constants.DB_STATUS.FAILED; } return status; }
/// <summary> /// Insert the use data to the user table from the parameter /// </summary> /// <param name="newUser"></param> /// <returns> /// Returns DB_STATUS /// </returns> public Constants.DB_STATUS Insert(User newUser) { Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN; try { inventory.AddToUsers(newUser); inventory.SaveChanges(); status = Constants.DB_STATUS.SUCCESSFULL; } catch (Exception e) { status = Constants.DB_STATUS.FAILED; } return status; }
/// <summary> /// Get user data of ther User table according to the User parameter /// </summary> /// <param name="user"></param> /// <returns></returns> public User GetUser(User user) { try { userObj = inventory.Users.Where(uObj => uObj.UserName.Equals(user.UserName) && uObj.Password.Equals(user.Password)).First(); } catch (Exception e) { userObj = null; } return userObj; }