Exemple #1
0
        private static void SeedAdmin(MyServerDbContext context)
        {
            var user = new User
            {
                UserName  = "******",
                Email     = "*****@*****.**",
                FirstName = "Atanas",
                LastName  = "Georgiev",
                CreatedOn = DateTime.Now
            };

            var res1 = PathHelper.UserManager.CreateAsync(user, "chnageme").Result;

            context.SaveChanges();

            var role = Queryable.First <IdentityRole>(context.Roles, x => x.Name == MyServerRoles.Admin.ToString());

            context.UserRoles.Add(new IdentityUserRole <string>()
            {
                RoleId = role.Id, UserId = user.Id
            });
            context.SaveChanges();

            var album = new Album(Common.ImageGallery.Constants.NoCoverId)
            {
                CreatedOn = DateTime.Now,
                AddedById = user.Id,
                TitleBg   = "No Image Album",
                TitleEn   = "No Image Album",
            };

            context.Albums.Add(album);
            context.SaveChanges();

            var image = new MyServer.Data.Models.Image(Common.ImageGallery.Constants.NoCoverId)
            {
                CreatedOn = DateTime.Now,
                AddedById = user.Id,
                AlbumId   = album.Id,

                // Cover = album,
                Height    = 267,
                Width     = 400,
                LowHeight = 267,
                LowWidth  = 400,
                MidHeight = 267,
                MidWidth  = 400,
                FileName  = Common.ImageGallery.Constants
                            .NoCoverImage,
                OriginalFileName = Common.ImageGallery
                                   .Constants.NoCoverImage
            };

            context.Images.Add(image);
            context.SaveChanges();

            album.CoverId = image.Id;
            context.Albums.Update(album);
            context.SaveChanges();
        }
Exemple #2
0
 public JsonController(
     IUserService userService,
     UserManager <User> userManager,
     SignInManager <User> signInManager,
     MyServerDbContext context)
     : base(userService, userManager, signInManager, context)
 {
 }
Exemple #3
0
 public AlbumController(
     IUserService userService,
     UserManager <User> userManager,
     SignInManager <User> signInManager,
     MyServerDbContext dbContext,
     IAlbumService albumService)
     : base(userService, userManager, signInManager, dbContext)
 {
     this.albumService = albumService;
 }
Exemple #4
0
 public UploadController(
     IUserService userService,
     UserManager <User> userManager,
     SignInManager <User> signInManager,
     MyServerDbContext dbContext,
     IImageService imageService)
     : base(userService, userManager, signInManager, dbContext)
 {
     this.imageService = imageService;
 }
 public BaseController(
     IUserService userService,
     UserManager <User> userManager,
     SignInManager <User> signInManager,
     MyServerDbContext dbContext)
 {
     this.UserService   = userService;
     this.userManager   = userManager;
     this.signInManager = signInManager;
     this.dbContext     = dbContext;
 }
Exemple #6
0
        public BasePageModel(
            IUserService userService,
            UserManager <User> userManager,
            SignInManager <User> signInManager,
            MyServerDbContext dbContext,
            IHttpContextAccessor httpContextAccessor)
        {
            this.UserService   = userService;
            this.userManager   = userManager;
            this.signInManager = signInManager;
            this.dbContext     = dbContext;

            this.UserProfile =
                this.UserService.GetAll().FirstOrDefault(u => u.UserName == httpContextAccessor.HttpContext.User.Identity.Name);
        }
 public AlbumController(
     IAlbumService albumService,
     ILocationService locationService,
     IImageService imageService,
     IUserService userService,
     UserManager <User> userManager,
     SignInManager <User> signInManager,
     MyServerDbContext dbcontext,
     IFileService fileService)
     : base(userService, userManager, signInManager, dbcontext)
 {
     this.albumService    = albumService;
     this.locationService = locationService;
     this.imageService    = imageService;
     this.fileService     = fileService;
 }
Exemple #8
0
 public UserService(IRepository <User> users, MyServerDbContext context, UserManager <User> userManager)
 {
     this.users       = users;
     this.context     = context;
     this.userManager = userManager;
 }
 public IndexModel(IUserService userService, UserManager <User> userManager, SignInManager <User> signInManager, MyServerDbContext dbContext, IHttpContextAccessor httpContextAccessor) : base(userService, userManager, signInManager, dbContext, httpContextAccessor)
 {
 }
Exemple #10
0
 private static void SeedRoles(MyServerDbContext context)
 {
     context.Roles.Add(new IdentityRole(MyServerRoles.Admin.ToString()));
     context.SaveChanges();
 }