//Add new User public string AddUser(string name, string surname, string username, string password, int id) { try { var checkUser = GetUserByUsername(username); if (checkUser != null) { throw new Exception("Username already exsist"); } CommonLayer.user u = new CommonLayer.user(); u.name = name; u.surname = surname; u.username = username; u.password = password; u.userTypeID = id; this.Entity.users.AddObject(u); this.Entity.SaveChanges(); return("Added Successfully :)"); } catch (Exception ex) { return(ex.Message); } }
public void GetUser(string username) { JavaScriptSerializer js = new JavaScriptSerializer(); CommonLayer.user data = new CommonLayer.user(); var getUser = DataLayer.LecturerRepository.Instance.GetUserByUsername(username); data.username = getUser.username; data.password = getUser.password; data.name = getUser.name; data.surname = getUser.surname; data.userTypeID = getUser.userTypeID; Context.Response.Write(js.Serialize(data)); }
//Delete User By username public bool DeleteUser(string username) { try { CommonLayer.user us = GetUserByUsername(username); this.Entity.users.DeleteObject(us); this.Entity.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
//Update User public string UpdateUser(string name, string surname, string username, string password, int id) { try { CommonLayer.user us = GetUserByUsername(username); us.name = name; us.surname = surname; us.password = password; us.userTypeID = id; this.Entity.SaveChanges(); return("Updated :)"); } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// Create a new user object. /// </summary> /// <param name="name">Initial value of the name property.</param> /// <param name="surname">Initial value of the surname property.</param> /// <param name="username">Initial value of the username property.</param> /// <param name="password">Initial value of the password property.</param> /// <param name="userTypeID">Initial value of the userTypeID property.</param> public static user Createuser(global::System.String name, global::System.String surname, global::System.String username, global::System.String password, global::System.Int32 userTypeID) { user user = new user(); user.name = name; user.surname = surname; user.username = username; user.password = password; user.userTypeID = userTypeID; 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); }
//Add new User public string AddUser(string name, string surname, string username, string password, int id) { try { var checkUser = GetUserByUsername(username); if (checkUser != null) { throw new Exception("Username already exsist"); } CommonLayer.user u = new CommonLayer.user(); u.name = name; u.surname = surname; u.username = username; u.password = password; u.userTypeID = id; this.Entity.users.AddObject(u); this.Entity.SaveChanges(); return "Added Successfully :)"; } catch (Exception ex) { return ex.Message; } }