Ejemplo n.º 1
0
        public DTO.Animal UpdateAnimal(DTO.Animal animal)
        {
            using (var context = new SaguContext())
            {
                var animalToUpdate = context.Animals.Find(animal.Id);

                if (animalToUpdate == null)
                    throw new KeyNotFoundException();

                context.Entry(animalToUpdate).CurrentValues.SetValues(animal);
                context.SaveChanges();

                return animal;
            }
        }
Ejemplo n.º 2
0
        public DTO.Explorer UpdateExplorer(DTO.Explorer explorer)
        {
            using (var context = new SaguContext())
            {
                var explorerToUpdate = context.Explorers.Find(explorer.Id);

                if (explorerToUpdate == null)
                    throw new KeyNotFoundException();

                context.Entry(explorerToUpdate).CurrentValues.SetValues(explorer);
                context.SaveChanges();

                return explorer;
            }
        }
Ejemplo n.º 3
0
        public DTO.Area UpdateArea(DTO.Area area)
        {
            using (var context = new SaguContext())
            {
                var areaToUpdate = context.Areas.Include(a => a.Image).FirstOrDefault(a => a.Id == area.Id);

                if (areaToUpdate == null)
                    throw new KeyNotFoundException();

                areaToUpdate.Image = area.Image.Get(i => i.AsEntity()) ?? areaToUpdate.Image;
                context.Entry(areaToUpdate).CurrentValues.SetValues(area);

                context.SaveChanges();

                return area;
            }
        }