public IActionResult GetQuery(string from, string to) { try { DateTime fromDate = DateTime.Today; DateTime toDate = DateTime.Now; if (from != null || to != null) { fromDate = Convert.ToDateTime(from); toDate = Convert.ToDateTime(to); } ViewBag.From = fromDate.ToString("dd.MM.yyyy"); ViewBag.To = toDate.ToString("dd.MM.yyyy"); var claims = User.Claims.ToList(); RequestClass <QueryRequestData> request = new RequestClass <QueryRequestData>(); request.Login = claims[0].Value; request.Token = claims[1].Value; request.Password = claims[2].Value; request.Data = new QueryRequestData { From = fromDate, To = toDate }; ResponseClass <List <QueryModel> > response = _repository.GetQuery(request); if (response.Code != 0) { ViewBag.Message = "Не удалось получить отчет"; return(View()); } else { return(View(response.Data)); } } catch (Exception e) { ViewBag.Message = e.Message; return(View()); } }
public ResponseClass <List <QueryModel> > GetQuery(RequestClass <QueryListData> request) { try { if (!_repositoryGuard.IsValid(request.Login, request.Password, request.Token)) { throw new Exception("Неверные данные авторизации"); } ResponseClass <List <QueryModel> > response = new ResponseClass <List <QueryModel> >(); response.Data = _repositoryCabinet.GetQuery(request.Data, request.Login); response.Code = 0; response.Message = "Success"; return(response); } catch (Exception e) { ResponseClass <List <QueryModel> > response = new ResponseClass <List <QueryModel> >(); response.Code = -1; response.Message = e.Message; return(response); } }