public GetMyPendingIncomingMailboxResponse GetSearchInMailbox(string comp, string text, string from, string to) { var result = new GetMyPendingIncomingMailboxResponse(); 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); } try { result.ModelList = helper.GetIncomingMailbox(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); }
public List <OutDocumentModel> GetMyPendingOutcomingMailbox(OutDocumentFilterModel filter) { var result = new List <OutDocumentModel>(); var tmp = context.OutcomingMailbox.Where(m => (string.IsNullOrEmpty(filter.SearchText) || m.DocumentCode.ToLower().Contains(filter.SearchText.ToLower()) || m.RequestedByName.ToLower().Contains(filter.SearchText.ToLower()) || m.DocumentSubject.ToLower().Contains(filter.SearchText.ToLower()) || m.DestinationCompany.ToLower().Contains(filter.SearchText.ToLower()))).OrderByDescending(x => x.RequestDate).Take(50); if (tmp != null) { result = tmp.ToList().ConvertAll(ToModel); } return(result); }
public List <InboxDocumentModel> GetIncomingMailbox(OutDocumentFilterModel filter) { var result = new List <InboxDocumentModel>(); var tmp = context.InboxDocument.Where(m => (string.IsNullOrEmpty(filter.SearchText) || m.DocumentCode.ToLower().Contains(filter.SearchText.ToLower()) || m.CompanyName.ToLower().Contains(filter.SearchText.ToLower()) || m.DocumentSubject.ToLower().Contains(filter.SearchText.ToLower()) || m.FromCompany.ToLower().Contains(filter.SearchText.ToLower())) && (!filter.SearchDateFrom.HasValue || m.DocumentDate >= filter.SearchDateFrom.Value) && (!filter.SearchDateTo.HasValue || m.DocumentDate <= filter.SearchDateTo.Value)).OrderByDescending(x => x.DocumentDate).Take(50); if (tmp != null) { result = tmp.ToList().ConvertAll(ToModel); } return(result); }
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)); }