public void CreateRole(string roleName, string description)
        {
            Role Role = null;

            Role = Context.Roles.FirstOrDefault(Rl => Rl.RoleName == roleName);
            if (Role == null)
            {
                Role NewRole = new Role
                {
                    RoleName    = roleName,
                    Description = description
                };
                Context.Roles.Add(NewRole);
                Context.SaveChanges();
            }
        }
Пример #2
0
        public bool CreateUser(string username, string password, string email)
        {
            try
            {
                User NewUser = new User
                {
                    Username   = username,
                    Password   = password,
                    Email      = email,
                    CreateDate = DateTime.UtcNow,
                };

                Context.Users.Add(NewUser);
                Context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }