コード例 #1
0
        //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);
            }
        }
コード例 #2
0
        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));
        }
コード例 #3
0
 //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);
     }
 }
コード例 #4
0
 //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);
     }
 }
コード例 #5
0
 /// <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;
 }
コード例 #6
0
 /// <summary>
 /// Deprecated Method for adding a new object to the users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTousers(user user)
 {
     base.AddObject("users", user);
 }
コード例 #7
0
        //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;
            }
        }
コード例 #8
0
        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));
        }