/// <summary> /// Chargement de la liste des films /// (Passe par une lecture du fichier Json) /// </summary> private void Load() { try { if (!File.Exists(DataFilePosition.Film)) { var file = File.Create(DataFilePosition.Film); file.Close(); } string json = File.ReadAllText(DataFilePosition.Film); var filmsFromJson = JsonConvert.DeserializeObject <List <Film> >(json); foreach (Film film in filmsFromJson) { film.Director = directorService.GetDirector(film.DirectorId); } _films = new List <Film>(filmsFromJson); } catch (Exception e) { Logger.LogMessage(e.Message); } }
public async Task <IActionResult> Get(int id) { var customer = await _directorService.GetDirector(c => c.Id == id); if (customer == null) { return(NotFound()); } return(Ok(customer)); }
public async Task <IHttpActionResult> GetAsync(string directorName) { await Task.Yield(); try { var dir = directorService.GetDirector(directorName); return(Ok(dir)); } catch (DataBaseException) { return(Content(HttpStatusCode.NotFound, $"{directorName} does not exist in our servers")); } }