Beispiel #1
0
        public async Task <ActionResult> AtualizarAnuncio([FromBody] AnuncioWebmotorsUpdateDto anuncioDto)
        {
            var existeAnuncio = _repositoryQuery.Query <AnuncioWebmotors>()
                                .FirstOrDefault(x => x.Id == anuncioDto.Id);

            if (existeAnuncio == null)
            {
                return(NotFound("Anuncio não encontrado"));
            }

            var anuncio = _mapper.Map <AnuncioWebmotors>(anuncioDto);

            await _anuncioWebmotorsService.AtualizarAnuncio(anuncio);

            return(Ok());
        }
        public async Task <ActionResult> Get(int status, int numRecords)
        {
            if ((numRecords <= 0) || (numRecords > 100))
            {
                numRecords = 5;
            }

            var query = _orderQueryRepository.Query();


            var currentUser = await _workContext.GetCurrentUser();

            if (!User.IsInRole("admin"))
            {
                query = query.Where(x => x.ORDER_TYPE == currentUser.VendorId.ToString());
            }

            var model = query.OrderByDescending(x => x.UPDATE_TIME_SAP)
                        .Take(numRecords);

            return(Json(model));
        }