//GET:api/CollegeDetails/5 public async Task <IHttpActionResult> GetCollegeDetails(int id) { //db.Configuration.LazyLoadingEnabled = false; CollegeDetail college = new CollegeDetail(); college = db.CollegeDetails.Where(e => e.CollegeID == id).FirstOrDefault(); //college = db.CollegeDetails.Where(e => e.CollegeID == id).FirstOrDefault(); if (college == null) { return(NotFound()); } CollegeData cdata = new CollegeData(); List <Comments> list = new List <Comments>(); foreach (var item in college.Comments) { Comments comment = new Comments(); comment.CollegeID = item.CollegeID; comment.CommentDescription = item.CommentDescription; comment.CommentID = item.CommentID; comment.CreatedDate = item.CreatedDate; list.Add(comment); } cdata.comments = list; return(Ok(cdata)); }
public void CollegeDataProcessTest() { CollegeData colData = new CollegeData(settings, null); Group g1 = new Group() { Name = "grp", Students = new List <Student>() { new Student() { Name = "std1", Subjects = new List <Subject>() { new Subject() { Name = "AAA", SucessRate = 6 } } } } }; colData.AddGroup(g1); colData.Process(); Assert.Pass(); }
public void CollegeDataResultlSerializationTest() { IMySerializer ser = new MyJsonSerializer(); CollegeData colData = new CollegeData(settings, ser); Group g1 = new Group() { Name = "grp", Students = new List <Student>() { new Student() { Name = "std1", Subjects = new List <Subject>() { new Subject() { Name = "AAA", SucessRate = 6 } } } } }; colData.AddGroup(g1); colData.Process(); var str = colData.GetSerializedGroups(); Assert.IsTrue(str.Length > 0); }
public void FileCollegeDataLoaderLoadTest() { CollegeData testCollegeData = new CollegeData(settings, null); FileCollegeDataLoader loader = new FileCollegeDataLoader("SampleData.txt", null); var outputCollegeData = loader.LoadCollegeData(testCollegeData); Assert.Pass(); }
public void FileCollegeDataLoaderSerializerxmlTest() { IMySerializer ser = new MyXmlSerializer(); CollegeData testCollegeData = new CollegeData(settings, ser); FileCollegeDataLoader loader = new FileCollegeDataLoader("SampleData.txt", ser); var outputCollegeData = loader.LoadCollegeData(testCollegeData); string res = loader.GetSerializedErrors(); Assert.IsTrue(res.Length > 0); }
public void Load() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/collegeInfo.dat", FileMode.Open); CollegeData data = (CollegeData)bf.Deserialize(file); file.Close(); reputation = data.reputation; community = data.community; infrastructure = data.infrastructure; }
// void OnEnable(){ // Load (); // } // // void OnDiable(){ // Save (); // } public void Save() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/collegeInfo.dat"); CollegeData data = new CollegeData(); data.reputation = reputation; data.community = community; data.infrastructure = infrastructure; bf.Serialize(file, data); file.Close(); }
public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <CollegeContext>(); CollegeData.Initialize(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred seeding the DB"); } } host.Run(); }
private void ShowData() { try { var data = new Perguruan_Tinggi(); CollegeData.DataSource = data.RetrievingData(); CollegeData.Refresh(); if (CollegeData.Columns.Count > 0) { CollegeData.Columns[0].Visible = false; CollegeData.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; CollegeData.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; CollegeData.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } CollegeData.ClearSelection(); } catch (Exception er) { Console.WriteLine("ERROR : Anggota_KMB.RetrivingData" + er.Message); } }
public CollegeController() { colleges = CollegeData.GetCollegesFromCSV("college_costs.csv"); }