Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var input = File.ReadAllLines("input.txt");

            Console.WriteLine("Part One: {0} trees encountered.", Ski(input, (3, 1)));

            var p2 = Ski(input, (1, 1), (3, 1), (5, 1), (7, 1), (1, 2));

            Console.WriteLine(
                "Part Two: {0} trees encountered.",
                p2
                );
        }
        public List <int> Get(int height, int age, string style)
        {
            Person person          = new Person(height, age, style);
            Ski    recommendedSkis = new Ski(person);

            return(recommendedSkis.lengthSpan);
        }
Ejemplo n.º 3
0
        public void Test_Add_Element_To_Db()
        {
            MockDb      db   = new MockDb();
            IUnitOfWork unit = new UnitOfWork(db, db.Ski, db.Boots, db.Helmets, db.Bindings);

            Ski ski = new Ski
            {
                Id       = 12,
                Brand    = "Rossignol",
                Model    = "Pro t",
                Price    = 299M,
                Category = SkiCategory.Race
            };

            Boot boot = new Boot
            {
                Id       = 12,
                Brand    = "Fischer",
                Model    = "Cax",
                Price    = 120M,
                Category = BootCategory.CrossCountry
            };

            db.Ski.Add(ski);
            db.Boots.Add(boot);
            Assert.AreEqual(7, db.Ski.Set.Count);
            Assert.AreEqual(7, db.Boots.Set.Count);
        }
Ejemplo n.º 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Ski ski = db.Ski.Find(id);

            db.Ski.Remove(ski);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public void Classic_MaxLength207()
        {
            Person person          = new Person(200, 10, "classic");
            Ski    recommendedSkis = new Ski(person);

            Assert.Equal(207, recommendedSkis.lengthSpan[0]);
            Assert.Equal(207, recommendedSkis.lengthSpan[1]);
        }
Ejemplo n.º 6
0
        public void Length170_Age10_Classic()
        {
            Person person          = new Person(170, 10, "classic");
            Ski    recommendedSkis = new Ski(person);

            Assert.Equal(190, recommendedSkis.lengthSpan[0]);
            Assert.Equal(190, recommendedSkis.lengthSpan[1]);
        }
Ejemplo n.º 7
0
        public void Length170_Age10_Skate()
        {
            Person person          = new Person(170, 10, "skate");
            Ski    recommendedSkis = new Ski(person);

            Assert.Equal(180, recommendedSkis.lengthSpan[0]);
            Assert.Equal(185, recommendedSkis.lengthSpan[1]);
        }
Ejemplo n.º 8
0
        public void Length150_Age5_Skate()
        {
            Person person          = new Person(150, 5, "skate");
            Ski    recommendedSkis = new Ski(person);

            Assert.Equal(160, recommendedSkis.lengthSpan[0]);
            Assert.Equal(170, recommendedSkis.lengthSpan[1]);
        }
Ejemplo n.º 9
0
        public ActionResult DeleteConfirmed(int id)
        {
            Ski    ski   = unit.SkiRepo.GetElement(x => x.Id == id);
            string categ = ski.Category.ToString();

            unit.SkiRepo.Delete(ski);
            unit.Commit();
            return(RedirectToAction("Index", "Skis", new { categ = categ }));
        }
Ejemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "Id,Price,Model,Brand,Length,Category")] Ski ski)
 {
     if (ModelState.IsValid)
     {
         unit.SkiRepo.Update(ski);
         unit.Commit();
         return(RedirectToAction("Index", "Skis", new { categ = ski.Category.ToString() }));
     }
     return(View(ski));
 }
Ejemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "id,naziv,drzavaId")] Ski ski)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ski).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.drzavaId = new SelectList(db.Drzava, "id", "naziv", ski.drzavaId);
     return(View(ski));
 }
        public void Put(int id, [FromBody] Ski value)
        {
            Ski ski = GetId(id);

            if (ski != null)
            {
                ski.Id        = value.Id;
                ski.SkiLength = value.SkiLength;
                ski.SkiType   = value.SkiType;
                ski.Price     = value.Price;
            }
        }
Ejemplo n.º 13
0
        public ActionResult Create([Bind(Include = "id,naziv,drzavaId")] Ski ski)
        {
            if (ModelState.IsValid)
            {
                db.Ski.Add(ski);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.drzavaId = new SelectList(db.Drzava, "id", "naziv", ski.drzavaId);
            return(View(ski));
        }
Ejemplo n.º 14
0
        public async Task <Ski> GetSki(int lenght, int age, Style style)
        {
            Ski ski = await AgeCheck(lenght, age, style);

            if (ski != null)
            {
                return(ski);
            }

            ski = await GetSizeByStyle(lenght, style);

            return(ski);
        }
Ejemplo n.º 15
0
    protected void Unesi_Click(object sender, EventArgs e)
    {
        //Create new ski
        Ski skijaliste = new Ski();

        skijaliste.naziv    = tb_naziv.Text;
        skijaliste.drzavaId = Int32.Parse(ddl_drzave.SelectedValue);
        //Add it to locasl collection
        db.Ski.Add(skijaliste);
        //Update database, generate SQL...
        db.SaveChanges();
        showSki();
    }
Ejemplo n.º 16
0
        // GET: Skis/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ski ski = db.Ski.Find(id);

            if (ski == null)
            {
                return(HttpNotFound());
            }
            return(View(ski));
        }
Ejemplo n.º 17
0
        // GET: Skis/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ski ski = unit.SkiRepo.GetElement(x => x.Id == id);

            if (ski == null)
            {
                return(HttpNotFound());
            }
            return(View(ski));
        }
Ejemplo n.º 18
0
        // GET: Skis/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ski ski = db.Ski.Find(id);

            if (ski == null)
            {
                return(HttpNotFound());
            }
            ViewBag.drzavaId = new SelectList(db.Drzava, "id", "naziv", ski.drzavaId);
            return(View(ski));
        }
        public void Delete(int id)
        {
            Ski ski = GetId(id);

            Skis.Remove(ski);
        }
 public void InsertSki([FromBody] Ski value)
 {
     Skis.Add(value);
 }
Ejemplo n.º 21
0
 /// <summary>
 ///     This function sends a keystroke to the Final Fantasy XIV window
 /// </summary>
 /// <param name="key">Key to press (see Virtual Key Codes for information)</param>
 /// <param name="keyup">Should we keyup after keydown (default: true)</param>
 /// <param name="delay">(Optional) Delay between keypress down and keypress up</param>
 public void SendKey(IntPtr key, bool keyup = true, int delay = 100)
 {
     Ski.SendKeyPress((SendKeyInput.VKKeys)key, keyup, delay);
 }
 public void Post([FromBody] Ski value)
 {
     skis.Add(value);
 }
Ejemplo n.º 23
0
 // Start is called before the first frame update
 void Awake()
 {
     player = GameObject.FindGameObjectWithTag("Player").GetComponent <Ski>();
     player.setCamera(this);
 }