Ejemplo n.º 1
0
        public IHttpActionResult  GetWeightTicketsReport([FromUri] WeightTicketReportFilterModel filters)
        {
            GetReportDataResponse response = new GetReportDataResponse();

            try
            {
                response.ReportData = weightTicketsBL.GetWeightTicketsReport(filters);
                response.Success    = true;
            }
            catch (Exception ex)
            {
                response.ErrorMessage = "Error. " + ex.Message;
                response.Success      = false;
            }
            return(Ok(response));
        }
Ejemplo n.º 2
0
 public void LoadReport()
 {
     try
     {
         HttpClient client = new HttpClient();
         client.BaseAddress = new Uri(baseUrl);
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token.access_token);
         HttpResponseMessage response = client.GetAsync(string.Format("{0}?{1}", getReportAction, view.CurrentFilters.GetUrlQuery())).Result;
         response.EnsureSuccessStatusCode();
         GetReportDataResponse getReportDataResponse = response.Content.ReadAsAsync <GetReportDataResponse>().Result;
         view.ReportData = getReportDataResponse.ReportData;
     }
     catch (Exception ex)
     {
         StackTrace st = new StackTrace();
         StackFrame sf = st.GetFrame(0);
         MethodBase currentMethodName = sf.GetMethod();
         Guid       errorId           = Guid.NewGuid();
         //Log error here
         view.HandleException(ex, currentMethodName.Name, errorId);
     }
 }
Ejemplo n.º 3
0
        public void TestGetWeightTicketReport()
        {
            //Test this one in prod
            baseUrl = @"http://lasmargaritas.azurewebsites.net/";
            Token      token  = TokenHelper.GetToken(baseUrl, "Melvin3", "MelvinPass3");
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(baseUrl);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token);
            WeightTicketReportFilterModel filter = new WeightTicketReportFilterModel();

            filter.CicleId          = 1;
            filter.WeightTicketType = (int)WeightTicketType.Producer;
            HttpResponseMessage response = client.GetAsync(string.Format("{0}?{1}", getReportAction, filter.GetUrlQuery())).Result;

            response.EnsureSuccessStatusCode();
            GetReportDataResponse getReportDataResponse = response.Content.ReadAsAsync <GetReportDataResponse>().Result;

            Assert.IsTrue(getReportDataResponse.Success);
            Assert.IsTrue(getReportDataResponse.ReportData != null);
            // Assert.IsTrue(getReportDataResponse.ReportData.Count > 0);
        }