Exemplo n.º 1
0
        public ActionResult Create(YearViewModel model)
        {
            var events = new List<Event>();
            var currentDate = model.StartDate;
            var index = 0;
            while (currentDate < model.EndDate)
            {
                events.Add(new Event
                {
                    Date = currentDate,
                    EventNumber = index,
                });

                currentDate = currentDate.AddDays(7);
            }

            var scenario = new Scenario();
            if (model.ScenarioId.HasValue)
                scenario = _session.SingleById<Scenario>(model.ScenarioId.Value);
            else
                scenario.Name = model.ScenarioName;

            var year = new Year
            {
                Events = events,
                Name = model.YearName,
                PlayableCategories = _session.Set<Category>().ToList(),
                PlayableRaces = _session.Set<Race>().ToList()

            };
            scenario.Years.Add(year);
            _session.Add(scenario);
            _session.Commit();

            return RedirectToAction("Index");
        }
Exemplo n.º 2
0
        public string Populate()
        {
            var animateur = new Animateur
            {
                Email = "*****@*****.**",
                FirstName = "Gab",
                LastName = "Lorquet",
                Username = "******",
                Password = "******".ToSHA1(),
            };
            _session.Add(animateur);

            var joueur = new Player
            {
                FirstName = "Test",
                LastName = "Test",
                Email = "*****@*****.**",
                Username = "******",
                DateOfBirth = new DateTime(2000, 01, 01)
            };
            _session.Add(joueur);
            _session.Commit();

            BuildArcane();
            BuildDivine();
            BuildNature();
            BuildMartial();
            BuildChasse();
            BuildRoublard();

            BuildRaces(_session.Set<Category>().ToList());

            BuildEvents();

            var sc = new Scenario
            {
                Name = "Guerre Mazérienne",
                Years = new List<Year>
                {
                    new Year
                    {
                        Name = "2016",
                        Current = true,
                        PlayableCategories = _session.Set<Category>().ToList(),
                        PlayableRaces = _session.Set<Race>().ToList(),
                        Events = _session.Set<Event>().ToList()
                    }
                }
            };

            _session.Add(sc);
            _session.Commit();

            return _session.Set<Event>().Count().ToString();
        }