Exemplo n.º 1
0
        public async Task <IHttpActionResult> GetOrderHomePageInformation()
        {
            var zones = await _locationService.GetAvailableActiveZones();

            if (zones == null)
            {
                return(Ok(new ResponseModel <string>(ResponseStatus.NotFound, null, "No zone available.")));
            }
            var promoOffer = await _promoOfferBusiness.GetPromoOfferForUser();

            var promo = promoOffer == null ? null : new PromoOfferResponse
            {
                PromoText = promoOffer.Text,
                Amount    = promoOffer.Amount
            };
            var response = new OrderHomePageResponse
            {
                Zones = zones,
                Promo = promo
            };

            return(Ok(new ResponseModel <OrderHomePageResponse>(ResponseStatus.Ok, response, "")));
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> GetOrderHomePageInformationWithDevice(DeviceStatus status)
        {
            if (string.IsNullOrWhiteSpace(status.RegistrationId))
            {
                return(BadRequest("Invalid data."));
            }
            var user = GetUserInformationFromToken();

            if (string.IsNullOrEmpty(user.UserId))
            {
                return(BadRequest("Invalid User."));
            }
            status.UserId = user.UserId;
            var registerAck = await _deviceStatusBusiness.RegisterDevice(status);

            var zones = await _locationService.GetAvailableActiveZones();

            if (zones == null)
            {
                return(Ok(new ResponseModel <string>(ResponseStatus.NotFound, null, "No zone available.")));
            }
            var promoOffer = await _promoOfferBusiness.GetPromoOfferForUser();

            var promo = promoOffer == null ? null : new PromoOfferResponse
            {
                PromoText = promoOffer.Text,
                Amount    = promoOffer.Amount
            };
            var response = new OrderHomePageResponse
            {
                Zones = zones,
                Promo = promo
            };

            return(Ok(new ResponseModel <OrderHomePageResponse>(ResponseStatus.Ok, response, "")));
        }