Merge branch 'develop' into feature/grafici_wp10
This commit is contained in:
Binary file not shown.
@@ -41,17 +41,23 @@ namespace Step.Controllers.WebApi
|
||||
}
|
||||
|
||||
[Route("programs"), HttpPost]
|
||||
public IHttpActionResult GetProgramHistoryData(DTONameFilter filter)
|
||||
public IHttpActionResult GetProgramHistoryData(DTOPageAndFilterModel filter)
|
||||
{
|
||||
StreamReader sr = new StreamReader("./Report/Programs.xml");
|
||||
XmlSerializer xmlSerializer = new XmlSerializer(typeof(DTOHistogramModel));
|
||||
DTOHistogramModel schema = xmlSerializer.Deserialize(sr) as DTOHistogramModel;
|
||||
|
||||
// FIlter
|
||||
schema.Occurrences = schema.Occurrences.Where(x =>
|
||||
x.ProgName.Contains(filter.Name) &&
|
||||
DateTime.Parse(x.StartDate) >= filter.StartDate && DateTime.Parse(x.EndDate) <= filter.EndDate
|
||||
|
||||
).ToList();
|
||||
)
|
||||
.ToList();
|
||||
|
||||
// Count pages
|
||||
schema.Pages = (int)Math.Ceiling((double)schema.Occurrences.Count() / (double)filter.PageSize);
|
||||
// Skip previous pages
|
||||
schema.Occurrences = schema.Occurrences.Skip(filter.Page - 1 * filter.PageSize).Take(filter.PageSize).ToList();
|
||||
|
||||
return Ok(schema);
|
||||
}
|
||||
@@ -67,6 +73,11 @@ namespace Step.Controllers.WebApi
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class DTOPageAndFilterModel : DTONameFilter
|
||||
{
|
||||
public int PageSize;
|
||||
public int Page;
|
||||
}
|
||||
/// <summary>
|
||||
/// PIE CHART
|
||||
/// </summary>
|
||||
@@ -159,6 +170,8 @@ namespace Step.Controllers.WebApi
|
||||
[XmlArray("programs")]
|
||||
[XmlArrayItem("program", typeof(DTOHistogramItemModel))]
|
||||
public List<DTOHistogramItemModel> Occurrences { get; set; }
|
||||
|
||||
public int Pages { get; set; }
|
||||
}
|
||||
|
||||
public class DTOHistogramItemModel
|
||||
|
||||
Reference in New Issue
Block a user