Ejemplo n.º 1
0
 public IActionResult Create([FromBody] Markt item)
 {
     if (item == null)
     {
         return(BadRequest());
     }
     _repository.Add(item);
     return(CreatedAtRoute("GetMarkt", new { id = item.Guid }, item));
 }
        public void Update(Markt item)
        {
            var itemToUpdate = _context.Markten.Where(a => a.Guid == item.Guid).FirstOrDefault();

            if (itemToUpdate != null)
            {
                itemToUpdate.Adres        = item.Adres;
                itemToUpdate.Beschrijving = item.Beschrijving;
                itemToUpdate.Naam         = item.Naam;
                itemToUpdate.Plaats       = item.Plaats;
                itemToUpdate.X            = item.X;
                itemToUpdate.Y            = item.Y;

                _context.Markten.Update(itemToUpdate);
                _context.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public IActionResult Update(string id, [FromBody] Markt item)
        {
            if (item == null || id == null)
            {
                return(BadRequest());
            }

            var markt = _repository.Find(id);

            if (markt == null)
            {
                return(NotFound());
            }

            _repository.Update(item);
            return(new NoContentResult());
        }
Ejemplo n.º 4
0
        public VillageDef(string name, int buildings, int pops, int prosp)
        {
            Name      = name;
            Buildings = buildings;
            Pops      = pops;
            Prosp     = prosp;
            Tavrn       tavern     = new Tavrn(Pops, Prosp);
            Church      church     = new Church(Pops, Prosp);
            Blacksmt    blacksmith = new Blacksmt(Pops, Prosp);
            Markt       market     = new Markt(Pops, Prosp);
            Arena       arena      = new Arena();
            TravelCoach trav       = new TravelCoach(Pops, Prosp);

            places[0] = tavern;
            places[1] = church;
            places[2] = blacksmith;
            places[3] = market;
            places[4] = arena;
            places[5] = trav;
        }
Ejemplo n.º 5
0
        public static void Initialize(MarktkaartDbContext context)
        {
            context.Database.EnsureCreated();

            // Look for any markten.
            if (context.Markten.Any())
            {
                return;   // DB has been seeded
            }

            var markten = new Markt[]
            {
                new Markt {
                    Guid = "025bfa35-6496-4f92-803e-0fcf185c3342", Naam = "Amersfoort", Beschrijving = "Leuke markt!", Adres = "Marktplein 1, Amersfoort", X = 144000, Y = 415000
                }
            };

            foreach (Markt m in markten)
            {
                context.Markten.Add(m);
            }
            context.SaveChanges();
        }
 public void Add(Markt item)
 {
     item.Guid = Guid.NewGuid().ToString();
     _context.Markten.Add(item);
     _context.SaveChanges();
 }