//returns ModelsMissingPhotos which contains a List<int> for models: //Production, ProductionPhotos, Sponsor, and Cast that dont have a picture. public static ModelsMissingPhotos FindModelsNoPics() { var admin = new AdminController(); ModelsMissingPhotos modelsWithNoPics = new ModelsMissingPhotos(); modelsWithNoPics.cast_members = admin.db.CastMembers.Where(p => p.PhotoId == null).OrderBy(p => p.CastMemberID). Select(p => p.CastMemberID).ToList(); modelsWithNoPics.productions = admin.db.Productions.Where(p => p.DefaultPhoto == null).OrderBy(p => p.ProductionId). Select(p => p.ProductionId).ToList(); modelsWithNoPics.production_photos = admin.db.ProductionPhotos.Where(p => p.PhotoId == null).OrderBy(p => p.ProPhotoId). Select(p => p.ProPhotoId).ToList(); modelsWithNoPics.sponsors = admin.db.Sponsors.Where(p => p.LogoId == null).OrderBy(p => p.LogoId). Select(p => p.SponsorId).ToList(); return(modelsWithNoPics); }
private void UpdateAdminSettings() { //flowchart: reads json file, deserializes, updates the values, serializes new string, and writes result to json file List <int> currentProd = FindCurrentProductions(); ModelsMissingPhotos miss = FindModelsNoPics(); string json_path = Server.MapPath(Url.Content("~/AdminSettings.json")); string json_string = null; using (StreamReader reader = new StreamReader(json_path)) { json_string = reader.ReadToEnd(); } JObject json_content = (JObject)JsonConvert.DeserializeObject(json_string); json_content.Property("current_productions").Value = JToken.FromObject(currentProd); json_content.Property("models_missing_photos").Value = JToken.FromObject(miss); string updated_json = JsonConvert.SerializeObject(json_content, Formatting.Indented); System.IO.File.WriteAllText(json_path, updated_json); }