public void Seed() { _ctx.Database.EnsureCreated(); // Kolla så att databasen finns. if (!_ctx.Tavlingar.Any()) { // Need to create sample data var lopp = new Lopp() { Distans = "8", Klass = "Tävling", }; _ctx.Lopp.AddRange(lopp); var tavling = new Tavling() { Ar = DateTime.Now.Year, Adress = "SEGERSJÖ 647, 715 93 Odensbacken", Lopp = new List <Lopp>() }; tavling.Lopp.Add(lopp); _ctx.Tavlingar.AddRange(tavling); var deltagare = new Deltagare() { FNamn = "Johan", ENamn = "Öhberg", Alder = 25, Kon = "Man" }; _ctx.Deltagare.AddRange(deltagare); var hund = new Hund() { DeltagareId = deltagare.Id, Namn = "Stella", Alder = 6, Ras = "Soft Coated Wheaten Terrier" }; _ctx.Hundar.AddRange(hund); var anmalan = new Anmalan() { AnmalningsDatum = DateTime.Now, LoppId = lopp.Id, DeltagareId = deltagare.Id }; _ctx.Anmalningar.AddRange(anmalan); // Utför ändringarna mot databasen _ctx.SaveChanges(); } }
public ActionResult DeleteConfirmed(int id) { Deltagare deltagare = db.Deltagare.Find(id); db.Deltagare.Remove(deltagare); db.SaveChanges(); return(RedirectToAction("Index")); }
// 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 ActionResult Edit([Bind(Include = "Id,Förnamn,Efternamn,Personnummer,RegistreringarID")] Deltagare deltagare) { if (ModelState.IsValid) { db.Entry(deltagare).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RegistreringarID = new SelectList(db.Registreringar, "ID", "Adress", deltagare.RegistreringarID); return(View(deltagare)); }
public void Setup() { var appSettingValFromStatic = ConfigurationManager.AppSettings["mySetting"]; var username = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location).AppSettings.Settings["username"].Value; var password = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location).AppSettings.Settings["password"].Value; context = new BI.Context.BildStudionDVContext(username, password); närvaroDb = new Närvaro(context); deltagareDb = new Deltagare(context, närvaroDb); deltagareVMLogic = new DeltagareVMLogic(deltagareDb); närvaroVMLogic = new NärvaroVMLogic(närvaroDb, deltagareDb); }
// GET: Deltagare/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Deltagare deltagare = db.Deltagare.Find(id); if (deltagare == null) { return(HttpNotFound()); } return(View(deltagare)); }
// GET: Deltagare/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Deltagare deltagare = db.Deltagare.Find(id); if (deltagare == null) { return(HttpNotFound()); } ViewBag.RegistreringarID = new SelectList(db.Registreringar, "ID", "Adress", deltagare.RegistreringarID); return(View(deltagare)); }
//This function will generate a database with Tävlingar and Deltagare. public void BuildDeltagareAndTävlingDataBase() { TävlingAndDeltagareDBContext context = new TävlingAndDeltagareDBContext(); Tävling tävling1 = new Tävling() { Namn = "Skidåkning", }; Deltagare deltagare1 = new Deltagare() { Namn = "Jonas Filuren", Tävling = tävling1 }; Deltagare deltagare2 = new Deltagare() { Namn = "Gustav Johnsson", Tävling = tävling1 }; Tävling tävling2 = new Tävling() { Namn = "Snowboarding", }; Deltagare deltagare3 = new Deltagare() { Namn = "Amanda Sörenson", Tävling = tävling2 }; Tävling tävling3 = new Tävling() { Namn = "Ishockey", }; Deltagare deltagare4 = new Deltagare() { Namn = "Amanda Gustavsson", Tävling = tävling3 }; context.Deltagare.Add(deltagare1); context.Deltagare.Add(deltagare2); context.Deltagare.Add(deltagare3); context.Deltagare.Add(deltagare4); context.SaveChanges(); }
public static string Deltagarnamn(this Deltagare deltagare) { return(deltagare.Förnamn + " " + deltagare.Efternamn); }
public NärvaroVMLogic(Närvaro _närvaroDb, Deltagare _deltagareDb) { närvaroDb = _närvaroDb; deltagareDb = _deltagareDb; }
public DeltagareVMLogic(Deltagare _deltagareDb) { deltagareDb = _deltagareDb; }