Exemple #1
0
        /// <summary>
        /// Resolves the filter value to that of what will be used in the query.
        /// </summary>
        /// <param name="filterValue"></param>
        /// <param name="context"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static object ResolveFilterValue(GetFilteredDataResult filter, OrgSys2017DataContext context, string token)
        {
            object value;
            var    userId = context.GetUserIDSession(token).SingleOrDefault()?.UserID;

            switch (filter.FilterValue) //substitutes current user id when needed, allows for dynamic query
            {
            case "UserID":
                value = userId;
                break;

            case "DIVISION_TREE":
                var resultList     = new List <string>();
                var userDivisionId = context.GetUserClientDivision(token);
                context.GetClientDivisions(userDivisionId)
                .ToList()
                .ForEach(x => resultList.Add("" + x.ClientID));
                value = $"({string.Join(",", resultList)})";
                break;

            case "DIVISION":
                value = context.GetUserClientDivision(token);
                break;

            default:
                value = filter.FilterValue;
                break;
            }

            return(filter.isFilterValueColumn.Value ? value : $"'{value}'");
        }
Exemple #2
0
 public HttpResponseMessage EmployeeOptionsInternal(string token, string clientId)
 {
     try
     {
         var         clientDivisions = con.GetClientDivisions(Convert.ToInt32(clientId));
         List <int?> divisionIds     = clientDivisions.Select(division => division.ClientID).ToList();
         var         userProfiles    = (from UserProfile in con.User_Profiles
                                        where divisionIds.Contains(UserProfile.ClientID)
                                        select UserProfile).ToList();
         return(Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(userProfiles)));
     }
     catch (Exception e)
     {
         ExceptionLog.LogException(e);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError));
     }
 }
Exemple #3
0
 public HttpResponseMessage GetClientDivisions(int ClientID)
 {
     try
     {
         var clients = context.GetClientDivisions(ClientID);
         return(Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(clients)));
     }
     catch (Exception e)
     {
         ExceptionLog.LogException(e);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError));
     }
 }