예제 #1
0
 // find user by user ID
 public static User findByUserId(User user)
 {
     using (var db = new NipunaDataContext())
     {
         var records = db.Users.SingleOrDefault(x => x.UserName == user.UserName);
         return(records);
     }
 }
예제 #2
0
 public static IEnumerable <UserRole> getAllUserRoles()
 {
     using (var db = new NipunaDataContext())
     {
         var record = db.UserRoles.ToList();
         return(record);
     }
 }
예제 #3
0
 // add new user
 public static bool addUser(User user)
 {
     using (var db = new NipunaDataContext())
     {
         db.Users.Add(user);
         db.SaveChanges();
         return(true);
     }
 }
예제 #4
0
 // update user account password
 public static bool UpdatePassword(User user)
 {
     using (var db = new NipunaDataContext())
     {
         var record = db.Users.SingleOrDefault(x => x.UserName == user.UserName);
         record.Password = user.Password;
         db.SaveChanges();
         return(true);
     }
 }
예제 #5
0
 // filter user datagrid
 public static IEnumerable <User> filterUsers(string search)
 {
     using (var db = new NipunaDataContext())
     {
         var record = db.Users.Where(x => x.UserName.StartsWith(search) ||
                                     x.SurName.StartsWith(search) ||
                                     x.FirstName.StartsWith(search) ||
                                     x.LastName.StartsWith(search)).ToList();
         return(record);
     }
 }
예제 #6
0
        // delete user account
        public static User deleteUser(User user)
        {
            using (var db = new NipunaDataContext())
            {
                var record = db.Users.SingleOrDefault(x => x.UserName == user.UserName);
                record.IsRemoved = user.IsRemoved;
                db.SaveChanges();

                return(record);
            }
        }
예제 #7
0
        // update user account
        public static User updateUser(User user)
        {
            using (var db = new NipunaDataContext())
            {
                var record = db.Users.SingleOrDefault(x => x.UserName == user.UserName);
                record.SurName   = user.SurName;
                record.FirstName = user.FirstName;
                record.LastName  = user.LastName;
                record.Nic       = user.Nic;
                user.ContactNo   = user.ContactNo;
                //user.Password = user.Password;
                user.Role = user.Role;

                db.SaveChanges();

                return(record);
            }
        }