public bool UpdateGeoZone(GeoZoneDto dto) { var geoZone = this.db.GeoZones.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.Id == dto.Id); if (geoZone != null) { geoZone.UpdatedOn = DateTime.Now; geoZone.UpdatedBy = dto.UpdatedBy; geoZone.Comment = dto.Comment; geoZone.Name = dto.Name; geoZone.CountryId = dto.Country.Id; this.db.SaveChanges(); return true; } return false; }
public bool AddGeoZone(GeoZoneDto dto) { if (!this.db.GeoZones.Any(x => x.DeletedOn.HasValue == false && x.Id == dto.Id)) { this.db.GeoZones.Add(new GeoZone { CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, UpdatedBy = dto.UpdatedBy, Comment = dto.Comment, Name = dto.Name, CountryId = dto.Country.Id }); this.db.SaveChanges(); return true; } return false; }