Example #1
0
 public Entities.CurrentWeather ToEntity(CurrentWeatherRequestDto request)
 {
     return(new Entities.CurrentWeather(
                default(long),
                request.CityName,
                CoordinatesMapper.ToEntity(request.Coordinates),
                request.Weather.Select(w => WeatherMapper.ToEntity(w)).ToList(),
                MainMapper.ToEntity(request.Main),
                WindMapper.ToEntity(request.Wind),
                CountryMapper.ToEntity(request.CountryInfo),
                RainMapper.ToEntity(request.Rain)
                ));
 }
Example #2
0
 public CurrentWeatherRequestDto ToDto(Entities.CurrentWeather entity)
 {
     return(new CurrentWeatherRequestDto()
     {
         Main = MainMapper.ToDto(entity.Main),
         Weather = entity.Weather.Select(w => WeatherMapper.ToDto(w)).ToList(),
         Wind = WindMapper.ToDto(entity.Wind),
         Rain = RainMapper.ToDto(entity.Rain),
         Coordinates = CoordinatesMapper.ToDto(entity.Coordinates),
         CountryInfo = CountryMapper.ToDto(entity.CountryInfo),
         CityName = entity.CityName
     });
 }
Example #3
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();

            GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings.Add(
                new QueryStringMapping("type", "json", new MediaTypeHeaderValue("application/json")));

            GlobalConfiguration.Configuration.Formatters.XmlFormatter.MediaTypeMappings.Add(
                new QueryStringMapping("type", "xml", new MediaTypeHeaderValue("application/xml")));

            AreaRegistration.RegisterAllAreas();
            Database.SetInitializer(new GameStoreContextDbInitializer());
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            // Creater map rule for WebApi
            MainMapper.MainMappers();
        }
Example #4
0
        public ActionResult Register(UserView userView)
        {
            if (userView.Captcha != (string)Session[CaptchaImage.CaptchaValueKey])
            {
                ModelState.AddModelError("Captcha", "Textfrom image entered not correct");
            }
            var anyUser = _service.EmailExist(userView.Email);

            if (anyUser)
            {
                ModelState.AddModelError("Email", "User with this email already existed");
            }
            if (ModelState.IsValid)
            {
                var user = (User)MainMapper.Map(userView, typeof(UserView), typeof(User));
                user.UserRoles = new List <Role> {
                    _service.GetRole("User")
                };
                _service.CreateUser(user);
                return(RedirectToAction("AllGames", "Game"));
            }
            return(View(userView));
        }