/// <summary> /// Get a List of all Classes /// </summary> /// <param name="schoolyearId">The ID of the school year to query Classes</param> /// <returns>The <see cref="List{Class}"/> of all returned Classes.</returns> public async Task <List <Class> > GetClasses(string schoolyearId) { //Get the JSON GetClasses classes = new GetClasses { @params = new GetClasses.Params() { schoolyearId = schoolyearId } }; //Send and receive JSON from WebUntis string requestJson = JsonConvert.SerializeObject(classes); string responseJson = await SendJsonAndWait(requestJson, _url, SessionId); //Parse JSON to Class ClassesResult result = JsonConvert.DeserializeObject <ClassesResult>(responseJson); string errorMsg = wus.LastError.Message; if (!SuppressErrors && errorMsg != null) { Logger.Append(Logger.LogLevel.Error, errorMsg); throw new WebUntisException(errorMsg); } //Return all the Classes return(new List <Class>(result.result)); }
public void GetRecord() { ClsTableData objtabeldata = new ClsTableData(); string cs = ConfigurationManager.ConnectionStrings["student_data"].ConnectionString; using (SqlConnection connection = new SqlConnection(cs)) { connection.Open(); SqlCommand command = connection.CreateCommand(); SqlTransaction transaction; transaction = connection.BeginTransaction("SampleTransaction"); command.Connection = connection; command.Transaction = transaction; List <GetClasses> listclspetticash = new List <GetClasses>(); listclspetticash.Clear(); command.CommandText = "select * from classes"; objadp = new SqlDataAdapter(command.CommandText, connection); objadp.SelectCommand.Transaction = transaction; datatable = new DataTable(); objadp.Fill(datatable); foreach (DataRow rdr in datatable.Rows) { GetClasses getGetClasses = new GetClasses(); getGetClasses.classes_id = rdr["classes_id"].ToString(); getGetClasses.classes_name = rdr["classes_name"].ToString(); listclspetticash.Add(getGetClasses); } objtabeldata.GetClasses = listclspetticash; List <GetStudentName> listGetStudentName = new List <GetStudentName>(); listGetStudentName.Clear(); command.CommandText = "select * from add_std_info"; objadp = new SqlDataAdapter(command.CommandText, connection); objadp.SelectCommand.Transaction = transaction; datatable = new DataTable(); objadp.Fill(datatable); foreach (DataRow rdr in datatable.Rows) { GetStudentName getGetClasses = new GetStudentName(); getGetClasses.std_id = rdr["std_id"].ToString(); getGetClasses.std_name = rdr["std_name"].ToString(); getGetClasses.std_father = rdr["std_father"].ToString(); getGetClasses.std_phone_no = rdr["std_phone_no"].ToString(); getGetClasses.classes_id = rdr["classes_id"].ToString(); listGetStudentName.Add(getGetClasses); } objtabeldata.GetStudentName = listGetStudentName; transaction.Commit(); } JavaScriptSerializer js = new JavaScriptSerializer(); Context.Response.Clear(); Context.Response.ContentType = "application/json"; Context.Response.AddHeader("content-length", js.Serialize(objtabeldata).Length.ToString()); Context.Response.Flush(); Context.Response.Write(js.Serialize(objtabeldata)); HttpContext.Current.ApplicationInstance.CompleteRequest(); }
public async Task <object> Get(GetClasses request) { Expression <Func <Class, bool> > filter = x => (request.Name == null || x.Name.Contains(request.Name)) && (request.DepartmentId == null || x.DepartmentId == request.DepartmentId); var classEntities = await _classService.GetAll(filter : filter, includeProperties : "Department"); var dtos = classEntities.ToList().ConvertAll(x => { var dto = x.ConvertTo <ClassDto>(); dto.DepartmentName = x.Department.Name; return(dto); }); return(new { Success = true, StatusCode = (int)HttpStatusCode.OK, Results = dtos, ItemCount = dtos.Count }); }
public Msg ReplyFromServer() { lock (ContainerLock()) { try { // Since every new Client reads the class // collection from the file, we have to // make sure, it has been written. Container().ClassCollection().Write(Transaction()); } catch (Exception) { } } var message = GetClasses.GetWriterForLength(Transaction(), Const4.IntLength + 1); ByteArrayBuffer writer = message.PayLoad(); writer.WriteInt(Container().ClassCollection().GetID()); writer.WriteByte(Container().StringIO().EncodingByte()); return(message); }