public IList<School> CreateSchools(IList<SchoolEnrollment> schoolEnrollments) { if(schoolEnrollments == null) { throw new ArgumentNullException("schoolEnrollments"); } List<School> schools = new List<School>(); //iteratve all schools and retrieve Lat/Long info from google foreach (var schoolEnrollment in schoolEnrollments) { System.Threading.Thread.Sleep(2200); GoogleGeocodeResponse geocodeResponse = _googleApiProxy.GetGeocodeAddressResponse(schoolEnrollment.LocationQuery); Location schoolLocation = GetLocationFromGeocodeResponse(geocodeResponse); string formattedAddress = GetFormattedAddressFromGeocodeResponse(geocodeResponse); var school = new School() { Name = schoolEnrollment.Name, EnrollmentCount = schoolEnrollment.EnrollmentCount, Category = schoolEnrollment.Category }; school.FullAddress = formattedAddress; school.Latitude = schoolLocation.Lat; school.Longitude = schoolLocation.Lng; schools.Add(school); } return schools; }
public static void Main() { // Used in development process. var school = new School() { Name = "Telerik Academy", Location = "Sofia" }; var firstMark = new Mark() { Subject = "math", Value = 5.00 }; var secondMark = new Mark() { Subject = "math", Value = 6.00 }; var thirdMark = new Mark() { Subject = "math", Value = 4.00 }; var fourthMark = new Mark() { Subject = "c#", Value = 6.00 }; var fifthMark = new Mark() { Subject = "js", Value = 5.00 }; var sixthMark = new Mark() { Subject = "css", Value = 4.00 }; var firstStudent = new Student() { FirstName = "Nikolay", LastName = "Kostov", Age = 21, School = school, Grade = 12, Marks = new List<Mark>() { secondMark, fourthMark } }; var secondStudent = new Student() { FirstName = "Doncho", LastName = "Minkov", Age = 24, School = school, Grade = 11, Marks = new List<Mark>() { firstMark, fifthMark } }; var thirdStudent = new Student() { FirstName = "Georgi", LastName = "Georgiev", Age = 25, School = school, Grade = 10, Marks = new List<Mark>() { thirdMark, sixthMark } }; //AddStudent(thirdStudent); //AddSchool(school); //var students = Client.GetAsync("api/students?subject=math&value=5.00").Result.Content.ReadAsAsync<IEnumerable<Student>>().Result; //foreach (var student in students) //{ // Console.WriteLine(student.FirstName); //} }
public static void AddSchool(School school) { var response = Client.PostAsJsonAsync("api/schools", school).Result; if (response.IsSuccessStatusCode) { Console.WriteLine("School \"{0}\" added!", school.Name); } else { Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); } }
private static Student MakeSimpleStudent(string firstName, string lastName, double mathValue) { var school = new School() { Name = "Telerik Academy", Location = "Sofia" }; var firstMark = new Mark() { Subject = "math", Value = mathValue }; var secondMark = new Mark() { Subject = "c#", Value = 6.00 }; var thirdMark = new Mark() { Subject = "js", Value = 5.00 }; var fourthMark = new Mark() { Subject = "css", Value = 4.00 }; var student = new Student() { FirstName = firstName, LastName = lastName, Age = 21, School = school, Grade = 12, Marks = new List<Mark>() { firstMark, secondMark, thirdMark, fourthMark } }; return student; }
protected static SchoolDto ConvertSchoolToDto(School school) { var schoolDto = new SchoolDto(); if (school != null) { if (school.SchoolId != 0) { schoolDto.SchoolId = school.SchoolId; } if (school.Name != null) { schoolDto.Name = school.Name; } if (school.Location != null) { schoolDto.Location = school.Location; } } return schoolDto; }