示例#1
0
 //register user
 public void RegisterNewUser(UsersViewModel userVM)
 {
     DBCarRent.User user = UserMapViewModelToModel(userVM);
     using (UsersRepository userRepository = new UsersRepository())
     {
         userRepository.RegisterUser(user);
     }
 }
示例#2
0
 //update user
 public void UpdateUser(UsersViewModel userVM)
 {
     DBCarRent.User user = UserMapViewModelToModel(userVM);
     using (UsersRepository userRepository = new UsersRepository())
     {
         var email = user.Email;
         userRepository.UpdateUser(email, user);
     }
 }
示例#3
0
 //get Users by id
 public UsersViewModel GetUserById(int id)
 {
     DBCarRent.User user = null;
     using (UsersRepository usersRepository = new UsersRepository())
     {
         user = usersRepository.GetUserById(id);
     }
     return(UserMapModelToViewModel(user));
 }
示例#4
0
        private AuthViewModel AuthMapModelToViewModel(DBCarRent.User user)
        {
            AuthViewModel userVM = new AuthViewModel();

            userVM.Email   = user.Email;
            userVM.IsAdmin = user.IsAdmin;

            return(userVM);
        }
示例#5
0
        //Model To ViewModel
        private UsersViewModel UserMapModelToViewModel(DBCarRent.User user)
        {
            UsersViewModel userVM = new UsersViewModel();

            userVM.UserName = user.UserName;
            userVM.Password = user.Password;
            userVM.FullName = user.FullName;
            userVM.Email    = user.Email;
            userVM.Sex      = user.Sex;
            userVM.Passport = user.Passport;
            userVM.IsAdmin  = user.IsAdmin;

            return(userVM);
        }
示例#6
0
        //ViewModel To Model
        private DBCarRent.User UserMapViewModelToModel(UsersViewModel userVM)
        {
            DBCarRent.User user = new DBCarRent.User();

            user.UserName = userVM.UserName;
            user.Password = userVM.Password;
            user.FullName = userVM.FullName;
            user.Email    = userVM.Email;
            user.Sex      = userVM.Sex;
            user.Passport = userVM.Passport;
            user.IsAdmin  = userVM.IsAdmin;

            return(user);
        }