public void RemoveCarTest() { Car car = new Car(); car.StateNumber = "1234-AA7"; using (ParkingDBContext context = contextFactory.CreateDbContext()) { ApplicationUser userEntity = new ApplicationUser(); userEntity.UserName = "******"; CarEntity carEntity = new CarEntity(); carEntity.StateNumber = car.StateNumber; context.Users.Add(userEntity); context.Cars.Add(carEntity); car.Id = carEntity.IdCar; UsersHaveCars uhc = new UsersHaveCars(); uhc.UserEntity = userEntity; uhc.CarEntity = carEntity; userEntity.UsersHaveCars = new List <UsersHaveCars>(); userEntity.UsersHaveCars.Add(uhc); context.SaveChanges(); } CarManager carManager = new CarManager(contextFactory); bool removedCar = carManager.RemoveCar(car); Assert.True(removedCar); }
public void GetParkedCarsTest() { string username = "******"; using (ParkingDBContext context = contextFactory.CreateDbContext()) { ApplicationUser user = new ApplicationUser(); user.UserName = username; CarEntity firstCar = new CarEntity(); firstCar.StateNumber = "1515-IO7"; context.Users.Add(user); UsersHaveCars uhc = new UsersHaveCars(); uhc.UserEntity = user; uhc.CarEntity = firstCar; user.UsersHaveCars = new List <UsersHaveCars>(); user.UsersHaveCars.Add(uhc); ParkingHistoryEntity parkingHistoryEntity = new ParkingHistoryEntity(); parkingHistoryEntity.IdCar = firstCar.IdCar; parkingHistoryEntity.IdUser = user.Id; parkingHistoryEntity.IdParking = 1; parkingHistoryEntity.Arrival = DateTime.Now; parkingHistoryEntity.Car = firstCar; parkingHistoryEntity.User = user; context.ParkingHistory.Add(parkingHistoryEntity); context.SaveChanges(); } CarManager carManager = new CarManager(contextFactory); List <Car> cars = carManager.GetParkedCars(username); Assert.NotEmpty(cars); }
public void AddCarTest() { Car car = new Car(); car.StateNumber = "1234-AA7"; car.Manufacturer = "Tesla"; car.Model = "X"; car.Year = 2017; car.Color = "Black"; string username = "******"; using (ParkingDBContext context = contextFactory.CreateDbContext()) { ApplicationUser entity = new ApplicationUser(); entity.UserName = username; context.Users.Add(entity); context.SaveChanges(); } CarManager carManager = new CarManager(contextFactory); Car addedCar = carManager.AddCar(car, username); Assert.NotNull(addedCar); Assert.Equal(car.StateNumber, addedCar.StateNumber); }
public Car CarUpdate(Car car) { if (car == null) { throw new ArgumentNullException(); } using (ParkingDBContext context = factory.CreateDbContext()) { CarEntity carEntity = context.Cars.Single(c => c.IdCar == car.Id); carEntity.StateNumber = car.StateNumber; carEntity.Manufacturer = car.Manufacturer; carEntity.Model = car.Model; carEntity.Color = car.Color; carEntity.Year = car.Year; context.Cars.Update(carEntity); int number = context.SaveChanges(); if (number == 0) { throw new InvalidOperationException(); } return(car); } }
public PocetnaViewModel() { Parkinzi = new ObservableCollection <Parking>(); ParkinziRezervacije = new ObservableCollection <ParkingRezervacija>(); //ParkingRezervacija = new ParkingRezervacija(); Parking = new Parking(); //Korisnik = new User(); Admin = new Administrator(); Vlasnik = new VlasnikParkinga(); RezervisanoOd = String.Format("{0:d MMMM yyyy, HH:mm}", DateTime.Now); RezervisanoDo = String.Format("{0:d MMMM yyyy, HH:mm}", DateTime.Now.AddHours(1.0)); RezervisiBtn = new RelayCommand <object>(Rezervisi); using (var db = new ParkingDBContext()) { foreach (var par in db.Parkingzi) { Parkinzi.Add(par); } foreach (var par in db.ParkingRezervacija) { ParkinziRezervacije.Add(par); } } }
public List <Car> GetParkedCars(string username) { if (string.IsNullOrWhiteSpace(username)) { throw new ArgumentNullException(username); } List <Car> cars = new List <Car>(); using (ParkingDBContext context = factory.CreateDbContext()) { ApplicationUser userEntity = context.Users.SingleOrDefault(us => us.UserName == username); if (userEntity != null) { var carEntities = context.Cars.Where(ca => ca.History.Any(hist => hist.User.UserName == username && hist.Departure == null)); foreach (var carEnt in carEntities) { Car car = new Car(); car.Id = carEnt.IdCar; car.StateNumber = carEnt.StateNumber; car.Manufacturer = carEnt.Manufacturer; car.Color = carEnt.Color; car.Model = carEnt.Model; car.Year = carEnt.Year; cars.Add(car); } } } return(cars); }
public Car AddCar(Car car, string username) { if (car == null) { throw new ArgumentNullException(); } if (string.IsNullOrWhiteSpace(username)) { throw new ArgumentNullException(username); } using (ParkingDBContext context = factory.CreateDbContext()) { ApplicationUser userEntity = context.Users.Single(us => us.UserName == username); CarEntity carEntity = new CarEntity(); carEntity.Manufacturer = car.Manufacturer; carEntity.Model = car.Model; carEntity.StateNumber = car.StateNumber; carEntity.Year = car.Year; carEntity.Color = car.Color; context.Cars.Add(carEntity); UsersHaveCars uhc = new UsersHaveCars(); uhc.UserEntity = userEntity; uhc.CarEntity = carEntity; carEntity.UsersHaveCars = new List <UsersHaveCars>(); carEntity.UsersHaveCars.Add(uhc); context.SaveChanges(); return(car); } }
public static void UseDataMigrations(this IApplicationBuilder app) { DataContextFactory factory = (DataContextFactory)app.ApplicationServices.GetService(typeof(DataContextFactory)); using (ParkingDBContext context = factory.CreateDbContext()) { context.Database.Migrate(); } }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; using (var db = new ParkingDBContext()) { db.Database.ApplyMigrations(); } }
public async Task <string> GetParkingNameByCarId(int carId) { string parkingName = ""; using (ParkingDBContext context = factory.CreateDbContext()) { ParkingHistoryEntity parkingHistoryEntity = await context.ParkingHistory.Include(p => p.Parking).Where(ph => ph.IdCar == carId).LastOrDefaultAsync(); parkingName = parkingHistoryEntity?.Parking?.Name; } return(parkingName); }
public Car GetCar(string statenumber) { using (ParkingDBContext context = factory.CreateDbContext()) { CarEntity carEntity = context.Cars.Single(c => c.StateNumber == statenumber); Car car = new Car(); car.Color = carEntity.Color; car.Id = carEntity.IdCar; car.Manufacturer = carEntity.Manufacturer; car.Model = carEntity.Model; car.StateNumber = carEntity.StateNumber; car.Year = carEntity.Year; return(car); } }
public bool RemoveCar(Car car) { if (car == null) { throw new ArgumentNullException(); } using (ParkingDBContext context = factory.CreateDbContext()) { CarEntity carEntity = context.Cars.Single(c => c.IdCar == car.Id); context.Cars.Remove(carEntity); int result = context.SaveChanges(); if (result != 1) { throw new InvalidOperationException(); } return(true); } }
public bool RemoveUser(User user) { if (user == null) { throw new ArgumentNullException(); } using (ParkingDBContext context = factory.CreateDbContext()) { ApplicationUser entity = context.Users.Single(us => us.UserName == user.Username); context.Users.Remove(entity); int number = context.SaveChanges(); if (number != 1) { throw new InvalidOperationException("Не удалось удалить из БД запись"); } return(true); } }
public Parking Depart(Car car) { if (car == null) { throw new ArgumentNullException(); } DateTime departure = DateTime.Now; Parking parking = new Parking(); using (ParkingDBContext context = factory.CreateDbContext()) { CarEntity carEntity = context.Cars.Single(ca => ca.StateNumber == car.StateNumber); var history = context.ParkingHistory.Where(ph => ph.IdCar == carEntity.IdCar).Last(); ParkingEntity parkingEntity = context.Parkings.Single(pa => pa.IdParking == history.IdParking); var carEntities = context.ParkingHistory.Include(ph => ph.Car).Where(ph => ph.IdParking == parkingEntity.IdParking && ph.Departure == null).Select(ph => ph.Car).ToList(); parking.ParkingName = parkingEntity.Name; parking.Latitude = parkingEntity.Latitude; parking.Longitude = parkingEntity.Longitude; foreach (var carEnt in carEntities) { User user = new User(); ApplicationUser userEntity = context.Users.Single(us => us.UsersHaveCars.Any(uhc => uhc.IdCar == carEnt.IdCar)); user.Username = userEntity.UserName; user.FirstName = userEntity.FirstName; user.LastName = userEntity.Lastname; user.UserPhoto = userEntity.UserPhoto; Car carInParking = new Car(); carInParking.StateNumber = carEnt.StateNumber; carInParking.Id = carEnt.IdCar; carInParking.Manufacturer = carEnt.Manufacturer; carInParking.Color = carEnt.Color; carInParking.Model = carEnt.Model; carInParking.Year = carEnt.Year; carInParking.Owner = user; ParkingHistoryEntity parkingHistoryIn = context.ParkingHistory.Last(phe => phe.IdCar == carEnt.IdCar); parking.AddCar(carInParking.StateNumber, carInParking.Owner, parkingHistoryIn.Arrival); } history.Departure = departure; context.SaveChanges(); return(parking); } }
public void CarUpdateTest() { Car car = new Car(); using (ParkingDBContext context = contextFactory.CreateDbContext()) { CarEntity carEntity = new CarEntity(); carEntity.StateNumber = "1234-AA7"; context.Cars.Add(carEntity); car.Id = carEntity.IdCar; context.SaveChanges(); } car.StateNumber = "1478 -AA7"; CarManager carManager = new CarManager(contextFactory); Car changedCar = carManager.CarUpdate(car); Assert.NotNull(changedCar); Assert.Equal(changedCar.StateNumber, car.StateNumber); }
public ListaParkingaViewModel() { Parkinzi = new ObservableCollection <Parking>(); ParkinziRezervacije = new ObservableCollection <ParkingRezervacija>(); using (var db = new ParkingDBContext()) { foreach (var p in db.Parkingzi) { Parkinzi.Add(p); } foreach (var p in db.ParkingRezervacija) { Parkinzi.Add(p); } } NavigationService = new NavigationService(); Back = new RelayCommand <object>(GoBack); }
public void RemoveUserTest() { using (ParkingDBContext context = contextFactory.CreateDbContext()) { ApplicationUser entity = new ApplicationUser(); entity.Email = "*****@*****.**"; entity.FirstName = "Trinity"; entity.Lastname = "Matrix"; entity.UserName = "******"; context.Users.Add(entity); context.SaveChanges(); } User user = new User(); user.Username = "******"; AuthenticationManager fakeAuthentication = new AuthenticationManager(contextFactory, fakeIdentityContextFactory.UserManager); bool removed = fakeAuthentication.RemoveUser(user); Assert.True(removed); }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter is User) { using (var db = new ParkingDBContext()) { foreach (var r in db.Rezervacije) { if (r.UserId == (e.Parameter as User).UserId) { ((ViewModel.RezervacijaViewModel) this.DataContext).Rezervacije.Add(r); } } foreach (var rezervacija in ((ViewModel.RezervacijaViewModel) this.DataContext).Rezervacije) { rezervacija.RezervisaniParking = db.ParkingRezervacija.FirstOrDefault(p => p.ParkingRezervacijaId == rezervacija.ParkingRezervacijaId); } } } }
public void Rezervisi(object parameter) { if (ParkingRezervacija == null) { return; } if (Korisnik == null) { Validacija.message("Da bi ste rezervisali parking morate biti prijavljeni", "Prijavi se"); return; } DateTime rezervacijaOd = DateTime.ParseExact(RezervisanoOd, "d MMMM yyyy, HH:mm", null); DateTime rezervacijaDo = DateTime.ParseExact(RezervisanoDo, "d MMMM yyyy, HH:mm", null); if (rezervacijaOd.CompareTo(rezervacijaDo) >= 0) { return; } UkupnaCijena = (ParkingRezervacija.Cijena * (int)(rezervacijaDo - rezervacijaOd).TotalHours).ToString(); Rezervacija rezervacija = new Rezervacija(); rezervacija.PocetakRezervacije = RezervisanoOd; rezervacija.KrajRezervacije = RezervisanoDo; rezervacija.Cijena = UkupnaCijena; rezervacija.ParkingRezervacijaId = ParkingRezervacija.ParkingRezervacijaId; rezervacija.UserId = Korisnik.UserId; using (var db = new ParkingDBContext()) { db.Rezervacije.Add(rezervacija); db.SaveChanges(); rezervacija.RezervisaniParking = db.ParkingRezervacija.FirstOrDefault(p => p.ParkingRezervacijaId == ParkingRezervacija.ParkingRezervacijaId); Validacija.message(rezervacija.ToString(), "Uspjesna rezervacija"); } }
public List <Car> GetCars(string username) { if (string.IsNullOrWhiteSpace(username)) { throw new ArgumentNullException(username); } List <Car> cars = new List <Car>(); using (ParkingDBContext context = factory.CreateDbContext()) { ApplicationUser userEntity = context.Users.SingleOrDefault(us => us.UserName == username); if (userEntity != null) { var carEntities = context.Cars.Where(c => c.UsersHaveCars.Any(uhc => uhc.IdUser == userEntity.Id)); //var carEntities = context.Cars.Where(c => c.UsersHaveCars.Any(uhc => uhc.IdUser == userEntity.Id)).Select(c => new Car //{ // StateNumber = c.StateNumber, // Manufacturer = c.Manufacturer, // Color = c.Color, // Model = c.Model, // Year = c.Year //}).ToList(); foreach (var carEnt in carEntities) { Car car = new Car(); car.Id = carEnt.IdCar; car.StateNumber = carEnt.StateNumber; car.Manufacturer = carEnt.Manufacturer; car.Color = carEnt.Color; car.Model = carEnt.Model; car.Year = carEnt.Year; cars.Add(car); } } } return(cars); }
public void DepartureTest() { User user = new User(); user.Username = "******"; Car car = new Car(); car.Owner = user; car.StateNumber = "1234"; Parking parking = new Parking(); parking.ParkingName = "Zion"; using (ParkingDBContext context = contextFactory.CreateDbContext()) { ParkingEntity parkingEntity = new ParkingEntity(); parkingEntity.Name = parking.ParkingName; context.Parkings.Add(parkingEntity); ApplicationUser userEntity = new ApplicationUser(); userEntity.UserName = user.Username; context.Users.Add(userEntity); CarEntity carEntity = new CarEntity(); carEntity.StateNumber = car.StateNumber; UsersHaveCars uhc = new UsersHaveCars(); uhc.UserEntity = userEntity; uhc.CarEntity = carEntity; userEntity.UsersHaveCars = new List <UsersHaveCars>(); userEntity.UsersHaveCars.Add(uhc); context.SaveChanges(); } ParkingManager parkingManager = new ParkingManager(contextFactory); parkingManager.Arrive(car, parking, car.Owner.Username); parkingManager.Depart(car); Assert.DoesNotContain(car, parking.Cars); }
public Parking Arrive(Car car, Parking parking, string username) { if (car == null) { throw new ArgumentNullException(); } if (parking == null) { throw new ArgumentNullException(); } DateTime arrival = DateTime.Now; using (ParkingDBContext context = factory.CreateDbContext()) { ApplicationUser userEntity = context.Users.Single(us => us.UserName == username); User user = new User(); user.Username = userEntity.UserName; user.FirstName = userEntity.FirstName; user.Email = userEntity.Email; user.LastName = userEntity.Lastname; user.Password = userEntity.PasswordHash; user.UserPhoto = userEntity.UserPhoto; CarEntity carEntity = context.Cars.Single(ca => ca.StateNumber == car.StateNumber); ParkingEntity parkingEntity = context.Parkings.Single(park => park.Name == parking.ParkingName); ParkingHistoryEntity historyEntity = new ParkingHistoryEntity(); historyEntity.IdCar = carEntity.IdCar; historyEntity.IdUser = userEntity.Id; historyEntity.IdParking = parkingEntity.IdParking; historyEntity.Arrival = arrival; context.ParkingHistory.Add(historyEntity); context.SaveChanges(); parking.AddCar(car.StateNumber, user, arrival); return(parking); } }
public List <Parking> GetParkings() { List <Parking> parkings = new List <Parking>(); using (ParkingDBContext context = factory.CreateDbContext()) { var parkingEntities = context.Parkings.Select(pe => new Parking { ParkingName = pe.Name, Longitude = pe.Longitude, Latitude = pe.Latitude }).ToList(); foreach (var parkEnt in parkingEntities) { Parking parking = new Parking(); parking.ParkingName = parkEnt.ParkingName; parking.Latitude = parkEnt.Latitude; parking.Longitude = parkEnt.Longitude; parkings.Add(parking); } } return(parkings); }
public void loginButton_click(object parameter) { using (var db = new ParkingDBContext()) { ErrorMessage = ""; if (Username == null || Password == null) { ErrorMessage = "Unesite podatke"; return; } foreach (User user in db.Useri) { if (user.Email == Username) { if (user.Sifra == (Validacija.createMD5(Password))) { NavigationService.Navigate(typeof(View.Pocetna), user); } break; } } ErrorMessage = "Pogresna sifra ili mail"; } }
public void RegistrujSe(object parameter) { using (var db = new ParkingDBContext()) { ImeErrorMessage = PrezimeErrorMessage = EmailErrorMessage = PasswordErrorMessage = RepeatPasswordErrorMessage = ""; bool flag = false; if (Ime == null || Prezime == null || Password == null || RepeatPassword == null || Email == null) { ErrorMessage = "Obavezno polje"; flag = true; return; } if (Ime.Length < 3 || Ime.Length > 12) { ImeErrorMessage = "Ime mora imati minimalno 3 i maximalno 12 karaktera"; flag = true; } if (Prezime.Length < 3) { PrezimeErrorMessage = "Prezime mora imati minimalno 3 i maximalno 12 karaktera"; flag = true; } if (!(new EmailAddressAttribute().IsValid(Email))) { EmailErrorMessage = "Pogresan email"; flag = true; } if (Password.Length < 8 || Password.Length > 24) { PasswordErrorMessage = "Password mora imati minimalno 8 i maximalno 24 karaktera"; flag = true; } if (RepeatPassword != Password) { RepeatPasswordErrorMessage = "Password se ne podudara"; flag = true; } if (!BoxChecked) { CheckBoxErrorMessage = "Morate prihvatiti uslove koristenja"; flag = true; } if (flag) { return; } User noviKorisnik = new User(); noviKorisnik.Ime = Ime; noviKorisnik.Prezime = Prezime; noviKorisnik.Email = Email; noviKorisnik.Sifra = Validacija.createMD5(Password); db.Useri.Add(noviKorisnik); db.SaveChanges(); try { Azure.User azureUser = new Azure.User(); azureUser.Ime = Ime; azureUser.Prezime = Prezime; azureUser.Email = Email; azureUser.Sifra = Validacija.createMD5(Password); userTbl.InsertAsync(azureUser); Validacija.message("Uspjesno ste se registrovali", "Cestitamo"); } catch (Exception e) { Validacija.message(e.Message, "Greska"); } NavigationService.Navigate(typeof(View.Pocetna), noviKorisnik); } }
internal FakeIdentityContextFactory() { IServiceCollection services = new ServiceCollection(); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); services.AddTransient <IConfiguration>((sp) => new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.Development.json").Build()); services.AddDbContext <ParkingDBContext>(); services.AddIdentity <ApplicationUser, ApplicationRole>(options => { options.Password.RequireDigit = false; options.Password.RequiredLength = 3; options.Password.RequireLowercase = false; options.Password.RequireNonAlphanumeric = false; options.Password.RequireUppercase = false; }) .AddEntityFrameworkStores <ParkingDBContext>() .AddDefaultTokenProviders(); HttpRequest request = new DefaultHttpContext().Request; HttpContextAccessor contextAccessor = new HttpContextAccessor { HttpContext = request.HttpContext }; services.AddSingleton <IHttpContextAccessor>(contextAccessor); IServiceProvider serviceProvider = services.BuildServiceProvider(); contextAccessor.HttpContext.RequestServices = serviceProvider; ParkingDBContext context = serviceProvider.GetRequiredService <ParkingDBContext>(); UserStore <ApplicationUser, ApplicationRole, ParkingDBContext, string> userStore = new UserStore <ApplicationUser, ApplicationRole, ParkingDBContext, string>(context); IOptions <IdentityOptions> serviceIOptions = serviceProvider.GetRequiredService <IOptions <IdentityOptions> >(); UserManager <ApplicationUser> serviceUserManager = serviceProvider.GetRequiredService <UserManager <ApplicationUser> >(); ILogger <UserManager <ApplicationUser> > serviceILoggerUserManager = serviceProvider.GetRequiredService <ILogger <UserManager <ApplicationUser> > >(); RoleStore <ApplicationRole, ParkingDBContext, string> roleStore = new RoleStore <ApplicationRole, ParkingDBContext, string>(context); RoleManager <ApplicationRole> serviceRoleManager = serviceProvider.GetRequiredService <RoleManager <ApplicationRole> >(); ILogger <RoleManager <ApplicationRole> > serviceILoggerRoleManager = serviceProvider.GetRequiredService <ILogger <RoleManager <ApplicationRole> > >(); IHttpContextAccessor serviceIHttpContextAccessor = serviceProvider.GetRequiredService <IHttpContextAccessor>(); SignInManager <ApplicationUser> serviceSignInManager = serviceProvider.GetRequiredService <SignInManager <ApplicationUser> >(); ILogger <SignInManager <ApplicationUser> > serviceILoggerSignInManager = serviceProvider.GetRequiredService <ILogger <SignInManager <ApplicationUser> > >(); IAuthenticationSchemeProvider serviceIAuthenticationSchemeProvider = serviceProvider.GetRequiredService <IAuthenticationSchemeProvider>(); UserManager = new UserManager <ApplicationUser>( userStore, serviceIOptions, serviceUserManager.PasswordHasher, serviceUserManager.UserValidators, serviceUserManager.PasswordValidators, serviceUserManager.KeyNormalizer, serviceUserManager.ErrorDescriber, serviceProvider, serviceILoggerUserManager ); RoleManager = new RoleManager <ApplicationRole>( roleStore, serviceRoleManager.RoleValidators, serviceRoleManager.KeyNormalizer, serviceRoleManager.ErrorDescriber, serviceILoggerRoleManager ); SignInManager = new SignInManager <ApplicationUser>( UserManager, serviceIHttpContextAccessor, serviceSignInManager.ClaimsFactory, serviceIOptions, serviceILoggerSignInManager, serviceIAuthenticationSchemeProvider ); }
internal FakeIdentityContextFactory(string databaseName) { if (string.IsNullOrEmpty(databaseName)) { throw new ArgumentException($"{nameof(databaseName)} is Null or Empty.", nameof(databaseName)); } IServiceCollection services = new ServiceCollection(); services.AddTransient <IConfiguration>((sp) => new ConfigurationBuilder() .AddInMemoryCollection(new Dictionary <string, string> { { "databaseName", databaseName } }).Build()); services.AddDbContext <FakeIdentityContext>(); services.AddIdentity <ApplicationUser, ApplicationRole>(options => { options.Password.RequireDigit = false; options.Password.RequiredLength = 3; options.Password.RequireLowercase = false; options.Password.RequireNonAlphanumeric = false; options.Password.RequireUppercase = false; }) .AddEntityFrameworkStores <FakeIdentityContext>() .AddDefaultTokenProviders(); HttpRequest request = new DefaultHttpContext().Request; HttpContextAccessor contextAccessor = new HttpContextAccessor { HttpContext = request.HttpContext }; services.AddSingleton <IHttpContextAccessor>(contextAccessor); IServiceProvider serviceProvider = services.BuildServiceProvider(); contextAccessor.HttpContext.RequestServices = serviceProvider; ParkingDBContext context = serviceProvider.GetRequiredService <FakeIdentityContext>(); UserStore <ApplicationUser, ApplicationRole, ParkingDBContext, string> userStore = new UserStore <ApplicationUser, ApplicationRole, ParkingDBContext, string>(context); IOptions <IdentityOptions> serviceIOptions = serviceProvider.GetRequiredService <IOptions <IdentityOptions> >(); UserManager <ApplicationUser> serviceUserManager = serviceProvider.GetRequiredService <UserManager <ApplicationUser> >(); ILogger <UserManager <ApplicationUser> > serviceILoggerUserManager = serviceProvider.GetRequiredService <ILogger <UserManager <ApplicationUser> > >(); RoleStore <ApplicationRole, ParkingDBContext, string> roleStore = new RoleStore <ApplicationRole, ParkingDBContext, string>(context); RoleManager <ApplicationRole> serviceRoleManager = serviceProvider.GetRequiredService <RoleManager <ApplicationRole> >(); ILogger <RoleManager <ApplicationRole> > serviceILoggerRoleManager = serviceProvider.GetRequiredService <ILogger <RoleManager <ApplicationRole> > >(); IHttpContextAccessor serviceIHttpContextAccessor = serviceProvider.GetRequiredService <IHttpContextAccessor>(); SignInManager <ApplicationUser> serviceSignInManager = serviceProvider.GetRequiredService <SignInManager <ApplicationUser> >(); ILogger <SignInManager <ApplicationUser> > serviceILoggerSignInManager = serviceProvider.GetRequiredService <ILogger <SignInManager <ApplicationUser> > >(); IAuthenticationSchemeProvider serviceIAuthenticationSchemeProvider = serviceProvider.GetRequiredService <IAuthenticationSchemeProvider>(); UserManager = new UserManager <ApplicationUser>( userStore, serviceIOptions, serviceUserManager.PasswordHasher, serviceUserManager.UserValidators, serviceUserManager.PasswordValidators, serviceUserManager.KeyNormalizer, serviceUserManager.ErrorDescriber, serviceProvider, serviceILoggerUserManager ); RoleManager = new RoleManager <ApplicationRole>( roleStore, serviceRoleManager.RoleValidators, serviceRoleManager.KeyNormalizer, serviceRoleManager.ErrorDescriber, serviceILoggerRoleManager ); SignInManager = new SignInManager <ApplicationUser>( UserManager, serviceIHttpContextAccessor, serviceSignInManager.ClaimsFactory, serviceIOptions, serviceILoggerSignInManager, serviceIAuthenticationSchemeProvider ); }