public ServiceResult GetLogs() { if (Request.Headers.Authorization == null || string.IsNullOrWhiteSpace(this.GetAuthToken(Request))) { return(ServiceResponse.Error("You must be logged in to access this functionality.")); } if (CurrentUser == null) { return(ServiceResponse.Error("You must be logged in to access this function.")); } int count = 0; DoseManager DoseManager = new DoseManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); List <dynamic> Doses = DoseManager.GetDoses(CurrentUser.AccountUUID).Cast <dynamic>().ToList(); DataFilter filter = this.GetFilter(Request); if (filter != null) { Doses = Doses.Filter(ref filter); //todo move the code below to the filter input string sortField = filter.SortBy?.ToUpper(); string sortDirection = filter.SortDirection?.ToUpper(); if (sortDirection == "ASC") { switch (sortField) { case "DOSEDATETIME": Doses = Doses.OrderBy(uob => uob.DoseDateTime).ToList(); break; case "NAME": Doses = Doses.OrderBy(uob => uob.Name).ToList(); break; } } else { switch (sortField) { case "DOSEDATETIME": Doses = Doses.OrderByDescending(uob => uob.DoseDateTime).ToList(); break; case "NAME": Doses = Doses.OrderByDescending(uob => uob.Name).ToList(); break; } } } return(ServiceResponse.OK("", Doses, count)); }
public void DoseManager_GetDoses() { DoseManager m = new DoseManager(new TreeMonDbContext(connectionKey)); Assert.IsTrue(m.GetDoses("a").Count > 0); }