예제 #1
0
        public async Task <IHttpActionResult> RegisterDevice(DeviceStatus status)
        {
            if (string.IsNullOrWhiteSpace(status.RegistrationId))
            {
                return(BadRequest("Invalid data."));
            }
            var user = GetDobiInformationFromToken();

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

            if (!registerAck)
            {
                return(Ok(new ResponseModel <string>(ResponseStatus.BadRequest, "Device could not be added.", "")));
            }
            return(Ok(new ResponseModel <string>(ResponseStatus.Ok, "Device added successfully.", "")));
        }
예제 #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, "")));
        }