Пример #1
0
        public static l2g_tbl_User UserToDataEntity(UserVM userVM)
        {
            var user = new l2g_tbl_User()
            {
                UserId   = userVM.UserId,
                Username = userVM.Username,
                Email    = userVM.Email,
                Password = userVM.Password
            };

            return(user);
        }
Пример #2
0
        public static UserVM UserToBusinessEntity(l2g_tbl_User user)
        {
            var userVM = new UserVM()
            {
                UserId   = user.UserId,
                Username = user.Username,
                Email    = user.Email,
                Password = user.Password
            };

            return(userVM);
        }
Пример #3
0
        public UserVM ValidateUser(string username, string password)
        {
            l2g_tbl_User user = db.l2g_tbl_User.FirstOrDefault(u =>
                                                               u.Username.Equals(username, StringComparison.OrdinalIgnoreCase) &&
                                                               u.Password == password);

            if (user == null)
            {
                return(null);
            }
            return(MappingConfig.UserToBusinessEntity(user));
        }
Пример #4
0
        public bool RegisterUser(UserVM userVM)
        {
            l2g_tbl_User user = MappingConfig.UserToDataEntity(userVM);

            user.CreatedDate = DateTime.Now;
            try
            {
                db.l2g_tbl_User.Add(user);
                db.SaveChanges();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }