Ejemplo n.º 1
0
        public void Delete(int id)
        {
            using (var db = new DbContext())
            {
                Entities.Pasture pasture = db.Pasture.Single(x => x.Id == id);

                db.Pasture.Remove(pasture);
                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public void Update(PastureDto dto)
        {
            using (var db = new DbContext())
            {
                Entities.Pasture pasture = db.Pasture.Single(x => x.Id == dto.Id);

                pasture.Section     = dto.Section;
                pasture.District    = dto.District;
                pasture.Forestry    = dto.Forestry;
                pasture.Description = dto.Description;
                pasture.CreatedDate = dto.CreatedDate;
                pasture.RemovedDate = dto.RemovedDate;

                db.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public void Insert(PastureDto dto)
        {
            var entity = new Entities.Pasture
            {
                Section     = dto.Section,
                District    = dto.District,
                Forestry    = dto.Forestry,
                Description = dto.Description,
                CreatedDate = dto.CreatedDate,
                RemovedDate = dto.RemovedDate
            };

            using (var db = new DbContext())
            {
                db.Pasture.Add(entity);
                db.SaveChanges();
            }
        }