public HttpResponseMessage GetRiderRequests(GetRiderRequestDto dto) { if (!ModelState.IsValid) { var errorList = (from item in ModelState.Values from error in item.Errors select error.ErrorMessage).ToArray(); return(new HttpResponseMessage(HttpStatusCode.BadRequest) { RequestMessage = Request, ReasonPhrase = JsonConvert.SerializeObject(errorList) }); } Logger.Info("Values sent from the App are below"); Logger.Info("Email Address: " + dto.RiderEmail); Logger.Info("Branch Code is: " + dto.BranchCode); var resp = courierService.GetAllRiderRequests(dto); if (resp == null) { return(new HttpResponseMessage(HttpStatusCode.BadRequest) { RequestMessage = Request, ReasonPhrase = "" }); } return(Request.CreateResponse(HttpStatusCode.OK, resp, "application/json")); }
public ResponseDto GetAllRiderRequests(GetRiderRequestDto dto) { try { Logger.Info("Just entered GetAllRiderRequests function"); var ResponseDto = new ResponseDto(); if (string.IsNullOrEmpty(dto.RiderEmail)) { ResponseDto.StatusCode = 1006; ResponseDto.Error = "Email Address cannot be empty"; ResponseDto.Message = ""; return(ResponseDto); } if (string.IsNullOrEmpty(dto.BranchCode)) { ResponseDto.StatusCode = 1006; ResponseDto.Error = "Branch code cannot be empty"; ResponseDto.Message = ""; return(ResponseDto); } Logger.Info("About to call GetRiderRequestList function"); var resp = GetRiderRequestList(dto); if (resp == null) { ResponseDto.StatusCode = 1001; ResponseDto.Message = ""; ResponseDto.Error = "Unable to get requests, please try again later."; return(ResponseDto); } Logger.Info("Response from GetRiderRequestList function is: " + JsonConvert.SerializeObject(resp)); ResponseDto.StatusCode = 1000; ResponseDto.Message = JsonConvert.SerializeObject(resp); ResponseDto.Error = ""; return(ResponseDto); } catch (Exception ex) { Logger.Error("GetAllRiderRequests function entered an exception"); Logger.Error(ex); return(null); } }
public IEnumerable <GetAllRequestForUserDto> GetRiderRequestList(GetRiderRequestDto dto) { try { Logger.Info("Just entered GetRiderRequestList function" + dto.RiderEmail); using (var db = new EOneContext()) { var list = db.ExecuteQuery <GetAllRequestForUserDto>("select * from Courier_Tracker where PickUp_Branch ='" + dto.BranchCode.Trim() + "' and Dispatch_Rider_Name is Null and Dispatch_Rider_Pickup_DateTime is Null ", new Object[] { }).ToList(); return(list); } } catch (Exception ex) { Logger.Error("GetRiderRequestList function entered an exception" + dto.RiderEmail); Logger.Error(ex); return(null); } }