public void Add(Celebrity celebrity) { //TODO: In real world I would use AutoNumber at database level celebrity.Id = celebrity.GetHashCode(); var celebrities = GetCelebrities(); celebrities.Add(celebrity); _jsonFileManager.Write(SerializeCelebrities(celebrities)); }
public void Update(int id, Celebrity celebrity) { var celebrities = GetCelebrities(); var celebrityToUpdate = celebrities.Single(c => c.Id == id); //TODO: In real world I would use AutoMapper celebrityToUpdate.Name = celebrity.Name; celebrityToUpdate.Age = celebrity.Age; celebrity.Country = celebrity.Country; _jsonFileManager.Write(SerializeCelebrities(celebrities)); }