public IActionResult GetAdvertisement(string uuid)
        {
            long logId = 0;

            try
            {
                logId = BaseApiManager.SaveLogs(uuid);
                if (!IsUuid(uuid))
                {
                    return(Error(logId, "verify uuid fail!"));
                }
                var    entityInterfaceAccount = GetInterfaceAccountByUuid(uuid);
                string companyId = entityInterfaceAccount.CompanyID;

                string advertisementId = Accessor.HttpContext.Request.GetQueryString("id");
                var    entity          = AdvertisementService.GetAdvertisement(SystemID, companyId, advertisementId);
                if (entity == null)
                {
                    return(Error(logId, "not data!"));
                }
                var details = AdvertisementDetailsService.GetAdvertisementDetailsByAdvertisementId(SystemID, companyId, advertisementId);
                var data    = new
                {
                    id      = entity.AdvertisementID,
                    name    = entity.Name,
                    remark  = entity.Remark.IIF(),
                    details = ToDetails(details)
                };
                return(Success(logId, "ok", data));
            }
            catch (Exception ex)
            {
                return(Error(logId, ex.Message));
            }
        }
        public IActionResult Add(string advertisementId)
        {
            try
            {
                string funcId = string.Empty;
                if (!IsAddPermission(advertisementId, out funcId))
                {
                    return(ToPermission(funcId));
                }

                if (string.IsNullOrWhiteSpace(advertisementId))
                {
                    return(View(new Extend_Advertisement()));
                }
                var entity = AdvertisementService.GetAdvertisement(SystemID, CompanyID, advertisementId);
                if (entity == null)
                {
                    return(View(new Extend_Advertisement()));
                }
                return(View(entity));
            }
            catch (Exception ex)
            {
                return(ToError(ex.Message));
            }
        }
示例#3
0
        public IViewComponentResult Invoke(Common.AdvertisementPosition advertisementPosition)
        {
            var advertisement = _advertisementService.GetAdvertisement(advertisementPosition);
            AdvertisementViewModel viewModel = null;
            var viewName = advertisementPosition == Common.AdvertisementPosition.BodyTop ? "TopAdvertisement" : (advertisementPosition == Common.AdvertisementPosition.BodyCenter ? "CenterAdvertisement" : "BottomAdvertisement");

            if (advertisement != null)
            {
                viewModel = _mapper.Map <AdvertisementViewModel>(advertisement);
            }
            return(View(viewName, viewModel));
        }
        public HttpResponseMessage Get(HttpRequestMessage request, long id)
        {
            try
            {
                var advert = _advertisementService.GetAdvertisement(id);
                if (advert != null)
                {
                    return(request.CreateResponse(HttpStatusCode.OK, advert));
                }

                return(request.CreateErrorResponse(HttpStatusCode.NotFound, "Advertisement not found"));
            }
            catch (Exception ex)
            {
                return(request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
示例#5
0
        public async Task <ActionResult <AdvertisementResponseDto> > Get(string id)
        {
            try
            {
                var advertisementResponseDto = await _AdvertisementService.GetAdvertisement(id);

                if (advertisementResponseDto is null)
                {
                    return(NotFound());
                }

                return(advertisementResponseDto);
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
        public async Task <IActionResult> Get(int id)
        {
            int?userId;

            if (User.Identity.IsAuthenticated)
            {
                userId = await GetCurrentUserId();
            }
            else
            {
                userId = null;
            }
            var result = await _advertisementService.GetAdvertisement(id, userId);

            if (result.IsSuccessful)
            {
                return(Ok(result.Payload));
            }
            return(NotFound());
        }