// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var username = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location).AppSettings.Settings["username"].Value; var password = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location).AppSettings.Settings["password"].Value; var context = new BildStudionDVContext(username, password); var deljobbDb = new DelJobb(context); var jobbDb = new Jobb(context, deljobbDb); var kundDb = new Kund(context, jobbDb); //kundjobbslogic var deljobbVm = new DelJobbVMLogic(deljobbDb); var jobbVM = new JobbVMLogic(jobbDb, deljobbVm); var kundVM = new KundVMLogic(kundDb, jobbVM); var inventarieDb = new Inventarie(context); var gruppDb = new Grupp(context, inventarieDb); var enhetDb = new Enhet(context, gruppDb); //inventarielogic var inventarieVM = new InventarieVMLogic(inventarieDb); var gruppVM = new GruppVMLogic(gruppDb, inventarieVM); var enhetVM = new EnhetVMLogic(enhetDb, gruppVM); //userlogic var usersDb = new UserProfiles(context); var userProfileVM = new UserProfileVMLogic(usersDb); var närvaroDb = new Närvaro(context); var deltagareDb = new Deltagare(context, närvaroDb); //närvarologic var deltagarVM = new DeltagareVMLogic(deltagareDb); var närvaroVM = new NärvaroVMLogic(närvaroDb, deltagareDb); DeltagarViewLogic deltagarViewLogic = new DeltagarViewLogic(deltagarVM, närvaroVM); MatlistaLogic matListaLogic = new MatlistaLogic(context, närvaroVM, deltagarVM); services.Add(new ServiceDescriptor(typeof(IDelJobbVMLogic), deljobbVm)); services.Add(new ServiceDescriptor(typeof(IJobbVMLogic), jobbVM)); services.Add(new ServiceDescriptor(typeof(IKundVMLogic), kundVM)); services.Add(new ServiceDescriptor(typeof(IInventarieVMLogic), inventarieVM)); services.Add(new ServiceDescriptor(typeof(IGruppVMLogic), gruppVM)); services.Add(new ServiceDescriptor(typeof(IEnhetVMLogic), enhetVM)); services.Add(new ServiceDescriptor(typeof(IUserProfileVMLogic), userProfileVM)); services.Add(new ServiceDescriptor(typeof(IDeltagareVMLogic), deltagarVM)); services.Add(new ServiceDescriptor(typeof(INärvaroVMLogic), närvaroVM)); services.Add(new ServiceDescriptor(typeof(IDeltagarViewLogic), deltagarViewLogic)); services.Add(new ServiceDescriptor(typeof(IMatlistaLogic), matListaLogic)); services.AddAuthentication("CookieAuthentication") .AddCookie("CookieAuthentication", config => { config.Cookie.Name = "UserLoginCookie"; config.LoginPath = "/Login/UserLogin"; }); services.AddControllersWithViews(); }
public MatlistaLogic(BildStudionDVContext _context, NärvaroVMLogic _närvaroLogic, DeltagareVMLogic _deltagarLogic) { context = _context; närvaroLogic = _närvaroLogic; deltagarLogic = _deltagarLogic; PrisDb = context.database.GetCollection <MatLådePris>("matlådapriser"); var list = PrisDb.Find(x => true).ToList(); if (list.Count == 0) { PrisDb.InsertOne(new MatLådePris { Pris = 55 }); } }
public UserProfiles(BildStudionDVContext _context) { context = _context; usersdb = context.database.GetCollection <UserProfileModel>("users"); if (usersdb.Find <UserProfileModel>(x => x.UserName == "admin").ToList().Count == 0) { var userModel = new UserProfileModel { UserName = "******", Password = "******" }; var newpassword = new PasswordHasher <UserProfileModel>().HashPassword(userModel, userModel.Password); userModel.Password = newpassword; usersdb.InsertOne(userModel); userModel = new UserProfileModel { UserName = "******", Password = "******" }; newpassword = new PasswordHasher <UserProfileModel>().HashPassword(userModel, userModel.Password); userModel.Password = newpassword; usersdb.InsertOne(userModel); } }
public Deltagare(BildStudionDVContext _context, Närvaro _närvaroDb) { context = _context; deltagaredb = context.database.GetCollection <DeltagareModel>("deltagare"); närvaroDb = _närvaroDb; }
public DelJobb(BildStudionDVContext _context) { context = _context; deljobbdb = context.database.GetCollection <DelJobbModel>("deljobbs"); }
public Jobb(BildStudionDVContext _context, DelJobb _delJobb) { context = _context; jobbdb = context.database.GetCollection <JobbModel>("jobbs"); delJobb = _delJobb; }
public Enhet(BildStudionDVContext _context, Grupp _grupp) { context = _context; grupp = _grupp; enhetdb = context.database.GetCollection <EnhetModel>("enheter"); }
public Inventarie(BildStudionDVContext _context) { context = _context; inventariedb = context.database.GetCollection <InventarieModel>("inventarier"); }
public Kund(BildStudionDVContext _context, Jobb _jobb) { context = _context; kunddb = context.database.GetCollection <KundModel>("kunder"); jobb = _jobb; }
public Närvaro(BildStudionDVContext _context) { context = _context; närvarodb = context.database.GetCollection <AttendenceModel>("närvaro"); }
public Grupp(BildStudionDVContext _context, Inventarie _inventarie) { context = _context; inventarie = _inventarie; gruppdb = context.database.GetCollection <GruppModel>("grupper"); }