public IActionResult GetCommercials()
        {
            try
            {
                /// <summary>
                /// Método para guardar request en logs
                /// </summary>
                _securityService.RequestLog("api/commercials/GetCommercials: " + "");

                GetCommercialsResponseModel responseModel = _commercialService.GetCommercials();
                switch (responseModel.Status)
                {
                case ResultStatus.SUCCESS:
                    return(Ok(_mapper.Map <List <CommercialDto> >(responseModel.Commercials)));

                case ResultStatus.BAD_REQUEST:
                    return(BadRequest());

                case ResultStatus.ACCESS_DENIED:
                    return(StatusCode(StatusCodes.Status401Unauthorized));

                case ResultStatus.NOT_AUTHORIZED:
                    return(StatusCode(StatusCodes.Status403Forbidden));

                default:
                    return(StatusCode(StatusCodes.Status500InternalServerError));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e));
            }
        }
Пример #2
0
        public ActionResult GetCommercial()
        {
            IReadOnlyCollection <Commercial> commercials = new List <Commercial>();

            var commercialResult = _commercialProvider.GetCommercials();

            if (commercialResult.IsSuccess())
            {
                commercials = commercialResult.GetSuccessResult();
            }

            var model = new CommercialViewModel {
                Commercials = commercials
            };

            return(PartialView("CommercialPartial", model));
        }