public bool UpdateCountry(CountryDto dto) { var country = this.db.Countries.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.Id == dto.Id); if (country != null) { country.UpdatedOn = DateTime.Now; country.UpdatedBy = dto.UpdatedBy; country.Comment = dto.Comment; country.Name = dto.Name; country.CountryCode = dto.CountryCode; country.ShortName = dto.ShortName; this.db.SaveChanges(); return true; } return false; }
public bool AddCountry(CountryDto country) { if (!this.db.Countries.Any(x => x.DeletedOn.HasValue == false && x.Name.Trim() == country.Name.Trim())) { this.db.Countries.Add(new Country { CreatedOn = DateTime.Now, UpdatedOn=DateTime.Now, UpdatedBy = country.UpdatedBy, Comment = country.Comment, Name = country.Name, ShortName = country.ShortName, CountryCode = country.CountryCode }); this.db.SaveChanges(); return true; } return false; }