public void Update(DeerLickerDto dto) { using (var db = new DbContext()) { Entities.DeerLicker deerLicker = db.DeerLicker.Single(x => x.Id == dto.Id); deerLicker.Count = dto.Count; deerLicker.Section = dto.Section; deerLicker.District = dto.District; deerLicker.Forestry = dto.Forestry; deerLicker.Description = dto.Description; db.SaveChanges(); } }
public void Insert(DeerLickerDto dto) { var entity = new Entities.DeerLicker { Count = dto.Count, Section = dto.Section, District = dto.District, Forestry = dto.Forestry, Description = dto.Description, MarketingYearId = dto.MarketingYearId }; using (var db = new DbContext()) { db.DeerLicker.Add(entity); db.SaveChanges(); } }
public void UpdateDeerLicker(DeerLickerViewModel model, int marketingYearId) { if (model.Section <= 0 || model.District <= 0 || String.IsNullOrWhiteSpace(model.Forestry)) { throw new Exception("Wystąpił nieznany błąd podczas edytowania lizawek."); } var dto = new DeerLickerDto { Id = model.Id, Count = model.Count, Section = model.Section, District = model.District, Forestry = model.Forestry, Description = model.Description }; _deerLickerDao.Update(dto); }
private IList <DeerLickerDto> ToDtos(IList <Entities.DeerLicker> entityList) { var dtos = new List <DeerLickerDto>(); foreach (Entities.DeerLicker entity in entityList) { var dto = new DeerLickerDto { Id = entity.Id, Count = entity.Count, Section = entity.Section, District = entity.District, Forestry = entity.Forestry, Description = entity.Description, MarketingYearId = entity.MarketingYearId }; dtos.Add(dto); } return(dtos); }