internal static void SeedModerator(TechSupportDbContext context)
        {
            const string moderatorEmail = "*****@*****.**";
            const string mderatorPassword = "******";

            if (context.Users.Any(u => u.Email == moderatorEmail))
            {
                return;
            }

            var userManager = new UserManager<User>(new UserStore<User>(context));

            var admin = new User
            {
                FirstName = "Gosho",
                LastName = "Moderatora",
                Email = moderatorEmail,
                Address = "Sopot",
                UserName = moderatorEmail
            };

            userManager.Create(admin, mderatorPassword);

            userManager.AddToRole(admin.Id, GlobalConstants.ModeratorRole);
            userManager.AddToRole(admin.Id, GlobalConstants.DefaultRole);

            context.SaveChanges();
        }
        internal static void SeedAdmin(TechSupportDbContext context)
        {
            const string AdminEmail = "*****@*****.**";
            const string AdminPassword = "******";

            if (context.Users.Any(u => u.Email == AdminEmail))
            {
                return;
            }

            var userManager = new UserManager<User>(new UserStore<User>(context));

            var admin = new User
            {
                FirstName = "Pesho",
                LastName = "Admina",
                Email = AdminEmail,
                Address = "Sopot",
                UserName = AdminEmail
            };

            userManager.Create(admin, AdminPassword);
            userManager.AddToRole(admin.Id, GlobalConstants.AdminRole);
            userManager.AddToRole(admin.Id, GlobalConstants.ModeratorRole);
            userManager.AddToRole(admin.Id, GlobalConstants.DefaultRole);

            context.SaveChanges();
        }
        public async Task UpdateUser(
             User user,
             string FirstName,
             string LastName,
             string City,
             string Phone,
             string About)
        {

            user.FirstName = FirstName;
            user.LastName = LastName;
            user.City = City;
            user.Phone = Phone;
            user.About = About;

            this.users.Update(user);
            await this.users.SaveChangesAsync();
        }
 public BaseOdataController(ITechSupportData data, User profile)
     : this(data)
 {
     this.UserProfile = profile;
 }
 public async Task DeleteUser(User user)
 {
     this.users.Delete(user);
     await this.users.SaveChangesAsync();
 }
        internal static void SeedUsers(TechSupportDbContext context)
        {
            var names = GetUserNames();

            var userManager = new UserManager<User>(new UserStore<User>(context));

            for (int i = 0; i < names.Length; i++)
            {
                var user = new User()
                {
                    UserName = string.Format("FakeUser{0}@FakeEmail.com", i + 1),
                    Email = string.Format("FakeUser{0}@FakeEmail.com", i + 1),
                    Address = string.Format("Karlovo{0}", i + 1),
                    FirstName = names[i].Substring(0, names[i].IndexOf(" ")),
                    LastName = names[i].Substring(names[i].IndexOf(" ") + 1)
                };

                userManager.Create(user, "qwerty");

                userManager.AddToRole(user.Id, GlobalConstants.DefaultRole);

                context.SaveChanges();
            }
        }