Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            ILoggerFactory loggerFactory,
            UserManager <ApplicationUser> userManager,
            RoleManager <IdentityRole> roleManager,
            ISAContext context)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            //ApplicationDataInitializer.SeedData(userManager, roleManager, context);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            using( var ctx = new ISAContext() )
            {

            }
        }
Exemplo n.º 3
0
 public CinemasController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IEmailService emailSender,
     ISmsSender smsSender,
     ILogger <BaseController> logger,
     ISAContext context,
     IMapper mapper)
     : base(userManager, signInManager, emailSender, smsSender, logger, context, mapper)
 {
 }
Exemplo n.º 4
0
 /// <summary>
 /// USED FOR CREATING DEFAULT TEST USERS
 /// TEST USERS FOLLOW THIS PATTERN,
 /// (IE FOR ROLE "TestRole")
 /// Username:       [email protected]
 /// Password:       Testrole2018!
 /// Assigned Role:  TestRole
 /// </summary>
 public static void SeedData
 (
     UserManager <ApplicationUser> userManager,
     RoleManager <IdentityRole> roleManager,
     ISAContext context
 )
 {
     if (!context.Database.EnsureCreated())
     {
         SeedEnumerations(context);
     }
     SeedRoles(roleManager);
     SeedUsers(userManager, context);
 }
Exemplo n.º 5
0
 public BaseController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IEmailService emailSender,
     ISmsSender smsSender,
     ILogger <BaseController> logger,
     ISAContext context,
     IMapper mapper)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _emailSender   = emailSender;
     _smsSender     = smsSender;
     _logger        = logger;
     _context       = context;
     _mapper        = mapper;
 }
Exemplo n.º 6
0
 public AccountController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IEmailService emailSender,
     ISmsSender smsSender,
     ILoggerFactory loggerFactory,
     IConfiguration appConfig,
     ISAContext context,
     RoleManager <IdentityRole> roleManager)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _emailSender   = emailSender;
     _smsSender     = smsSender;
     _logger        = loggerFactory.CreateLogger <AccountController>();
     _configuration = appConfig;
     _context       = context;
     _roleManager   = roleManager;
 }
Exemplo n.º 7
0
 public RepertoiresController(ISAContext context)
 {
     _context = context;
 }
Exemplo n.º 8
0
 public ISAContext Init()
 {
     return dbContext ?? (dbContext = new ISAContext());
 }
Exemplo n.º 9
0
 public ProjectionsController(ISAContext context)
 {
     _context = context;
 }
Exemplo n.º 10
0
 public FunZonesController(ISAContext context)
 {
     _context = context;
 }
Exemplo n.º 11
0
 public RepositoryBase(ISAContext context)
 {
     _context  = context;
     _entities = context.Set <T>();
 }
Exemplo n.º 12
0
 public CinemaRepo(ISAContext context) : base(context)
 {
 }
Exemplo n.º 13
0
        private static void SeedEnumerations(ISAContext context)
        {
            for (var i = 0; i < 3; i++)
            {
                var dummyUser = new UserProfile
                {
                    City         = $"City{i}",
                    EmailAddress = $"test{i}@test.mail",
                    FirstName    = $"FirstName{i}",
                    LastName     = $"LastName{i}",
                    TelephoneNr  = $"{i}{i}{i}{i}{i}{i}{i}"
                };

                if (context.UserProfiles.All(u => u.EmailAddress != dummyUser.EmailAddress))
                {
                    context.UserProfiles.Add(dummyUser);
                }
            }

            context.SaveChanges();

            var twoUsers   = context.UserProfiles.Take(2);
            var firstUser  = twoUsers.First();
            var secondUser = twoUsers.Skip(1).Take(1).First();

            if (context.FriendRequests.All(r => r.SenderId != firstUser.Id && r.ReceiverId != secondUser.Id))
            {
                context.FriendRequests.Add(new FriendRequest
                {
                    Sender   = firstUser,
                    Receiver = secondUser,
                    Status   = FriendshipStatus.Pending
                });
            }

            var projection = new Projection
            {
                Description = "desc",
                Duration    = new System.TimeSpan(2, 0, 0),
                Name        = "Projection 1",
                Type        = ProjectionTypeEnum.Movie
            };


            var rep = new Repertoire
            {
                Projections = new List <Projection> {
                    projection
                }
            };

            var cinema = new Cinema
            {
                Address     = "Address1",
                Name        = "Cinema1",
                Type        = DataAccess.Models.Enumerations.CinemaTypeEnum.Cinema,
                Repertoires = new List <Repertoire> {
                    rep
                }
            };

            var theater = new Theater()
            {
                Name = "Pozoriste Mladih"
            };

            var funZone = new FunZone()
            {
                Cinema = cinema
            };

            var funZoneTheater = new FunZone()
            {
                Theater = theater
            };

            var starWarsProps = new ThematicProps()
            {
                FunZone     = funZone,
                Description = "An almost brand new thematic prop for star wars! Used couple of times!",
                Image       = @"‪~/images/sw1.jpg",
                Price       = 1000,
                Name        = "Star wars gear",
                Publisher   = firstUser
            };

            var starTreckProp = new ThematicProps()
            {
                FunZone     = funZone,
                Description = "An almost brand new thematic prop for star treck! Used couple of times!",
                Image       = @"‪~/images/st1.jpg",
                Price       = 2000,
                Name        = "Star treck terminal"
            };

            var lotrProp = new ThematicProps()
            {
                FunZone     = funZone,
                Description = "An almost brand new thematic prop for LOTR! Used couple of times!",
                Image       = @"~/images/lordOfRings_ring.jpg",
                Price       = 200000,
                Name        = "LOTR ring on sales"
            };

            context.ThematicProps.Add(starWarsProps);
            context.ThematicProps.Add(starTreckProp);
            context.ThematicProps.Add(lotrProp);
            context.Projections.Add(projection);
            context.Repertoires.Add(rep);
            context.Cinemas.Add(cinema);
            context.FunZone.Add(funZone);
            context.FunZone.Add(funZoneTheater);

            context.SaveChanges();
        }
Exemplo n.º 14
0
        public static void SeedUsers(UserManager <ApplicationUser> userManager, ISAContext context)
        {
            foreach (var role in Constants.SYSTEM_ROLES)
            {
                var username = $"{role.ToLower()}";
                var email    = $"{username}@test.mail";
                var pw       = $"{char.ToUpper(username[0])}{username.Substring(1)}2018!";

                if (userManager.FindByNameAsync(email).Result == null)
                {
                    ApplicationUser user = new ApplicationUser
                    {
                        UserName = email,
                        Email    = email,
                    };

                    IdentityResult result = userManager.CreateAsync(user, pw).Result;

                    if (result.Succeeded)
                    {
                        //add roles to user
                        userManager.AddToRoleAsync(user, role).Wait();
                        //get activation code
                        var code = userManager.GenerateEmailConfirmationTokenAsync(user).Result;
                        //activate user
                        userManager.ConfirmEmailAsync(user, code).Wait();

                        context.UserProfiles.Add(new UserProfile
                        {
                            City         = $"{username} city",
                            EmailAddress = email,
                            FirstName    = username,
                            LastName     = username,
                            TelephoneNr  = email
                        });
                    }
                }
            }
            context.SaveChanges();

            foreach (var role in Constants.SYSTEM_ROLES)
            {
                var username = $"{role.ToLower()}";
                var email    = $"{username}@test.mail";
                var up       = context.UserProfiles.FirstOrDefault(x => x.EmailAddress == email);
                if (!(up is null))
                {
                    var ur = userManager.FindByNameAsync(email).Result;
                    if (ur != null)
                    {
                        ur.UserProfileId = up.Id;
                        var r = userManager.UpdateAsync(ur).Result;
                    }

                    if (up.Id == 4)
                    {
                        context.FriendRequests.AddRange(new List <FriendRequest>
                        {
                            new FriendRequest
                            {
                                SenderId   = 4,
                                Status     = FriendshipStatus.Accepted,
                                ReceiverId = 1
                            },

                            new FriendRequest
                            {
                                SenderId   = 4,
                                Status     = FriendshipStatus.Accepted,
                                ReceiverId = 2,
                            },

                            new FriendRequest
                            {
                                SenderId   = 4,
                                Status     = FriendshipStatus.Accepted,
                                ReceiverId = 3,
                            },
                        });

                        context.SaveChanges();
                    }
                }
            }
        }
Exemplo n.º 15
0
 public BidsController(ISAContext context, UserManager <ApplicationUser> userManager)
 {
     _context     = context;
     _userManager = userManager;
 }