Example #1
0
        public GetMyPendingOutcomingMailboxResponse GetMyPendingOutMailbox(string comp, string text, string from, string to)
        {
            var result = new GetMyPendingOutcomingMailboxResponse();

            try
            {
                var tmpFilter = new OutDocumentFilterModel();
                tmpFilter.SearchText = text;
                if (!string.IsNullOrEmpty(from))
                {
                    tmpFilter.SearchDateFrom = Convert.ToDateTime(from);
                }
                if (!string.IsNullOrEmpty(to))
                {
                    tmpFilter.SearchDateTo = Convert.ToDateTime(to);
                }
                result.ModelList = helper.GetMyPendingOutcomingMailbox(tmpFilter);
                if (result.ModelList.Count <= 0)
                {
                    result.Message = "No pending records found";
                }
            }
            catch (Exception ex)
            {
                result.Message = "An error occured while retrieving your information.";
            }
            return(result);
        }
Example #2
0
        public async Task <string> GetMyPendingOutMailbox(OutDocumentFilterModel document)
        {
            string actionEndpoint = "outmailbox/MyPendingOutMailbox";
            string queryParameter = string.Format("?comp={0}&text={1}&from={2}&to={3}", string.Empty, HttpUtility.UrlEncode(document.SearchText), document.SearchDateFrom != null ? document.SearchDateFrom.Value.ToString("yyyy-MM-dd") : string.Empty, document.SearchDateTo != null ? document.SearchDateTo.Value.ToString("yyyy-MM-dd") : string.Empty);
            GetMyPendingOutcomingMailboxResponse serviceResult = new GetMyPendingOutcomingMailboxResponse();
            List <OutDocumentModel> result = new List <OutDocumentModel>();

            using (var client = new HttpClient())
            {
                using (var request = new HttpRequestMessage(HttpMethod.Get, baseEndpoint + actionEndpoint + queryParameter))
                {
                    request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    using (HttpResponseMessage response = await client.SendAsync(request))
                    {
                        if (response.StatusCode == HttpStatusCode.OK)
                        {
                            serviceResult = JsonConvert.DeserializeObject <GetMyPendingOutcomingMailboxResponse>(response.Content.ReadAsStringAsync().Result);
                            result        = serviceResult.ModelList;
                        }
                    }
                }
            }
            return(JsonConvert.SerializeObject(result));
        }