public ResponseModel GetOrdersForStatus(GetOrdersForStatusRequestModel model) { var response = new ResponseModel { Success = false, Messages = new List <string>() }; try { if (model == null || string.IsNullOrEmpty(model.Status)) { response.Messages.Add("Data not mapped"); response.Data = model; } var data = OrderService.GetOrderForStatus(model); response.Data = data; response.Success = true; response.Messages.Add("Success"); } catch (Exception excep) { response.Messages.Add("Something bad happened."); } return(response); }
public static GetOrdersForStatus GetOrderForStatus(GetOrdersForStatusRequestModel model) { var response = new GetOrdersForStatus(); model.CurrentPage--; using (var dbContext = new DeliversEntities()) { var list = dbContext.Orders .Where( od => od.Status.ToLower() == model.Status).ToList(); if (list.Any()) { var take = list.Skip(model.CurrentPage * model.ItemsPerPage). Take(model.ItemsPerPage).ToList(); if (take.Any()) { var finals = take.Select(obj => obj.MappOrder()).ToList(); response.Orders = finals; } } response.ItemsPerPage = model.ItemsPerPage; response.CurrentPage++; response.TotalItems = list.Count; return(response); } }