Esempio n. 1
0
        public async Task <HttpResponseMessage> GetAllPreferences(string wb)
        {
            WorkbookManager manager = new WorkbookManager();

            try
            {
                //Dictionary<string, string> allWbPreferences = await manager.GetPreferenceDetailAsync(wb);
                List <WorkbookTab> allWbPreferences = await manager.GetTabDetailAsync(wb);

                ApiTabDetailsResponse response = new ApiTabDetailsResponse {
                    IsError = false
                };

                if (allWbPreferences != null)
                {
                    ApiTabDetails info = new ApiTabDetails();
                    info.Workbook = wb;
                    info.TabList  = allWbPreferences;
                    response.Content.Add(info);
                    response.StatusCode = HttpStatusCode.OK;
                }

                return(Request.CreateResponse <ApiTabDetailsResponse>(HttpStatusCode.OK, response));
            }
            catch (Exception ex)
            {
                var errorResponse = new ErrorResponse
                {
                    IsError    = true,
                    StatusCode = HttpStatusCode.InternalServerError,
                    Content    = new List <Error>()
                    {
                        { new Error {
                              Message = ex.Message, Workbook = wb
                          } }
                    }
                };

                return(Request.CreateResponse <ErrorResponse>(HttpStatusCode.InternalServerError, errorResponse));
            }
        }
Esempio n. 2
0
        public async Task <ActionResult> Details(string wb)
        {
            if (wb != null)
            {
                WebHelper           helper          = new WebHelper(getUrl());
                HttpResponseMessage responseMessage = await helper.CallService(IsWebApiCall : true
                                                                               , urlEndpoint : "wbinfo/tabs"
                                                                               , method : HttpMethod.Get
                                                                               , contentToPassToServer : new Dictionary <string, string> {
                    { "wb", wb }
                });

                if (responseMessage.IsSuccessStatusCode)
                {
                    var responseData = responseMessage.Content.ReadAsStringAsync().Result;

                    JsonSerializerSettings settings = new JsonSerializerSettings {
                        NullValueHandling = NullValueHandling.Include
                    };
                    var workbookInfo = JsonConvert.DeserializeObject <ApiTabDetailsResponse>(responseData, settings);

                    ApiTabDetails apiAllDetails = new ApiTabDetails();
                    if (workbookInfo.Content.Count > 0)
                    {
                        apiAllDetails = workbookInfo.Content[0];
                    }

                    return(View("details", apiAllDetails));
                }
                else
                {
                    ParameterError(responseMessage.Content.ReadAsStringAsync().Result);
                }
            }
            return(ParameterError());
        }