예제 #1
0
        public async Task <IHttpActionResult> Wearing(string itemName, string latlng)
        {
            if (string.IsNullOrEmpty(itemName))
            {
                return(BadRequest("The item name must not be empty"));
            }

            if (string.IsNullOrEmpty(latlng) || !(latlng.Contains(",")))
            {
                return(BadRequest("The coordinates could not be parsed"));
            }

            float lat, lng;

            if (!ParseLatLong(latlng, out lat, out lng))
            {
                return(BadRequest("The coordinates could not be parsed"));
            }

            var clothingItem = _clothingItemFactory.GetClothingItem(GetClothingItemTypeFromString(itemName));

            var forecast = await _forecastRepository.GetForecast(lat, lng);

            var isBeingWorn = clothingItem.IsBeingWorn(forecast);

            return(Ok(Enum.GetName(typeof(WearingClothingResult), isBeingWorn)));
        }
 public void ThrowANotImplementedExceptionWhenClothingItemTypeIsInvalid()
 {
     _factory.GetClothingItem(ClothingItemType.Invalid);
 }