/// <summary> /// Hämta alla avdelningar /// </summary> public DepartmentsResponse Get(GetDepartments request) { return(new DepartmentsResponse { Departments = DepartmentRepository.GetDepartments().Map(x => x.ConvertTo <DepartmentDTO>()) }); }
public async Task <object> Get(GetDepartments request) { Expression <Func <Department, bool> > filter = null; if (!request.Name.IsNullOrEmpty()) { filter = x => x.Name.Contains(request.Name); } var departmentEntities = await _departmentService.GetAll(filter : filter); var dtos = departmentEntities.ToList().ConvertAll(x => x.ConvertTo <DepartmentDto>()); return(new { Success = true, StatusCode = (int)HttpStatusCode.OK, Results = dtos, ItemCount = dtos.Count }); }
/// <summary> /// Get a List of all Departments /// </summary> /// <returns>The <see cref="List{Department}"/> of all returned Departments.</returns> public async Task <List <Department> > GetDepartments() { //Get the JSON GetDepartments department = new GetDepartments(); //Send and receive JSON from WebUntis string requestJson = JsonConvert.SerializeObject(department); string responseJson = await SendJsonAndWait(requestJson, _url, SessionId); //Parse JSON to Class DepartmentsResult result = JsonConvert.DeserializeObject <DepartmentsResult>(responseJson); string errorMsg = wus.LastError.Message; if (!SuppressErrors && errorMsg != null) { Logger.Append(Logger.LogLevel.Error, errorMsg); throw new WebUntisException(errorMsg); } //Return all the Departments return(new List <Department>(result.result)); }