public void Delete(int id) { using (var db = new DbContext()) { Entities.WateringPlace wateringPlace = db.WateringPlace.Single(x => x.Id == id); db.WateringPlace.Remove(wateringPlace); db.SaveChanges(); } }
public void Update(WateringPlaceDto dto) { using (var db = new DbContext()) { Entities.WateringPlace wateringPlace = db.WateringPlace.Single(x => x.Id == dto.Id); wateringPlace.Section = dto.Section; wateringPlace.District = dto.District; wateringPlace.Forestry = dto.Forestry; wateringPlace.Description = dto.Description; wateringPlace.CreatedDate = dto.CreatedDate; wateringPlace.RemovedDate = dto.RemovedDate; db.SaveChanges(); } }
public void Insert(WateringPlaceDto dto) { var entity = new Entities.WateringPlace { Section = dto.Section, District = dto.District, Forestry = dto.Forestry, Description = dto.Description, CreatedDate = dto.CreatedDate, RemovedDate = dto.RemovedDate }; using (var db = new DbContext()) { db.WateringPlace.Add(entity); db.SaveChanges(); } }