コード例 #1
0
        public async Task <ActionResult <IEnumerable <Agency> > > GetAllAsync(
            [FromServices] IAgencyRepository repository,
            [FromQuery] PagedAgencyParameters pageParameters,
            [FromQuery] bool?isCapital,
            [FromQuery] bool?isStation,
            [FromQuery] bool?isOpen
            )
        {
            var agencies = await repository.GetAll(
                pageParameters,
                isCapital,
                isStation,
                isOpen
                );

            var metadata = new
            {
                agencies.TotalCount,
                agencies.PageSize,
                agencies.CurrentPage,
                agencies.TotalPages,
                agencies.HasNext,
                agencies.HasPrevious
            };

            Response.Headers.Add(
                "X-Pagination",
                JsonSerializer.Serialize(metadata)
                );

            return(Ok(agencies));
        }
コード例 #2
0
        public IActionResult Index()
        {
            List <Agency>            agencies   = agencyRepository.GetAll().Data;
            List <SecurityClearance> clearances = securityRepo.GetAll().Data;

            ViewBag.ListOfAgencies   = agencies;
            ViewBag.ListOfClearances = clearances;

            return(View());
        }
コード例 #3
0
        public IActionResult Index()
        {
            var result = _agencyRepository.GetAll();

            if (result.Success)
            {
                return(View(result.Data));
            }
            else
            {
                throw new Exception(result.Messages[0]);
            }
        }
コード例 #4
0
        public IActionResult Index()
        {
            var response = agencyRepo.GetAll();

            if (response.Success)
            {
                return(View(response.Data));
            }
            else
            {
                return(BadRequest(response.Message));
            }
        }
コード例 #5
0
        public async Task UpdateAccountAsync(UserContextModel userContext, JsonPatchDocument <UpdateAgencyRequestModel> jsonPatch, CancellationToken ct)
        {
            Agency agency = await _agencyRepository.GetAll().Where(x => x.Id == userContext.AgencyId).Include
                                (x => x.Employees).FirstOrDefaultAsync();

            UpdateAgencyRequestModel jsonPatchDTO = _mapper.Map <UpdateAgencyRequestModel>(agency);

            jsonPatch.ApplyTo(jsonPatchDTO);

            _mapper.Map(jsonPatchDTO, agency);

            _agencyRepository.Update(agency);

            await _unitOfWork.SaveChangesAsync();

            //return jsonPatchDTO;
        }
コード例 #6
0
 public ResponseEntityVM GetAll()
 {
     try
     {
         var agencyList = _repository.GetAll();
         return(new ResponseEntityVM()
         {
             StatusCode = System.Net.HttpStatusCode.OK, Result = _mapper.Map <IEnumerable <AgencyVM> >(agencyList)
         });
     }
     catch (Exception ex)
     {
         return(new ResponseEntityVM()
         {
             StatusCode = System.Net.HttpStatusCode.InternalServerError, Message = $"There was an error getting the Agencies: {ex.Message}"
         });
     }
 }
コード例 #7
0
 public Agency[] Retrieve(GetAgenciesQuery query)
 {
     return(_agencyRepository.GetAll().ToArray());
 }
コード例 #8
0
 public IList <Agency> GetAll()
 {
     return(_agencyRepository.GetAll());
 }