Beispiel #1
0
        //Edit
        public void EditUser(UsersCustomClass user)
        {
            var result = _db.users.FirstOrDefault(e => e.Id == user.Id);

            if (!Exist(user) || result.email == user.Email)
            {
                result.name         = user.Name;
                result.surname      = user.Surname;
                result.email        = user.Email;
                result.password     = SHA.GenerateSHA512String(user.Password);
                result.isActive     = user.IsActive;
                result.categoriesId = user.CategoriesId;
            }
            _db.SaveChanges();
        }
Beispiel #2
0
        //Create
        public void CreateUser(UsersCustomClass user)
        {
            DateTime localDate = DateTime.Now;

            if (!Exist(user))
            {
                _db.users.Add(new users()
                {
                    name         = user.Name,
                    surname      = user.Surname,
                    email        = user.Email,
                    password     = SHA.GenerateSHA512String(user.Password),
                    loginDate    = localDate,
                    isActive     = user.IsActive,
                    categoriesId = user.CategoriesId,
                });
            }
            _db.SaveChanges();
        }
Beispiel #3
0
 public bool Exist(UsersCustomClass user)
 {
     return(_db.users.FirstOrDefault(e => e.email == user.Email) == null ? false : true);
 }