public string AddPlaceToChosen(string placeId)
        {
            if (!HttpContext.Request.IsAjaxRequest())
            {
                return(ToJson(SProcessResult.Convert(ProcessResults.Error)));
            }
            DefineLanguage(HttpContext);
            var places = GetChosenPlaces(HttpContext);

            if (places.Contains(placeId))
            {
                return(ToJson(new RouteProcessResult(false, true, Language.PlaceIsAlreadyInTheRoute)));
            }
            var    country      = GetCountry(HttpContext);
            string placeCountry = DataManager.Places.GetPlace(Convert.ToInt32(placeId)).Region.CountryId.ToString();

            if (country != null && country != placeCountry)
            {
                return(ToJson(new RouteProcessResult(false, false, Language.CountriesNotMatched)));
            }
            HttpContext.Response.SetCookie(SetCountry(placeCountry));
            places.Add(placeId);
            HttpContext.Response.SetCookie(SetChosenPlaces(places));
            return(ToJson(new RouteProcessResult(true, true, Language.PlaceWasAddedToTheRoute)));
        }
 public string RemovePublicRoute(string token, int routeId, int userId, Culture culture = Culture.En)
 {
     if (!CheckToken(token))
     {
         return(null);
     }
     return(ToJson(SProcessResult.Convert(DataManager.Routes.RemovePublicRoute(routeId, userId), culture)));
 }
 public string MakeRoutePublic(string token, int routeId, int userId, Translation translation, Culture culture = Culture.En)
 {
     if (!CheckToken(token))
     {
         return(null);
     }
     return(ToJson(SProcessResult.Convert(DataManager.Routes.MakeRoutePublic(routeId, userId, translation), culture)));
 }
 public string CreateRoute(string token, Route route, int[] places, Culture culture = Culture.En)
 {
     if (!CheckToken(token))
     {
         return(null);
     }
     return(ToJson(SProcessResult.Convert(DataManager.Routes.CreateRoute(route, places), culture)));
 }
 public string CheckIn(string token, int bookmarkId, int checkPointId, Culture culture = Culture.En)
 {
     if (!CheckToken(token))
     {
         return(null);
     }
     return(ToJson(SProcessResult.Convert(DataManager.Routes.CheckIn(bookmarkId, checkPointId), culture)));
 }
 public string AbortTracking(string token, int bookmarkId, Culture culture = Culture.En)
 {
     if (!CheckToken(token))
     {
         return(null);
     }
     return(ToJson(SProcessResult.Convert(DataManager.Routes.AbortTracking(bookmarkId), culture)));
 }
 public string AddBookmark(string token, int userId, int routeId, Culture culture = Culture.En)
 {
     if (!CheckToken(token))
     {
         return(null);
     }
     return(ToJson(SProcessResult.Convert(DataManager.Routes.AddBookmark(userId, routeId), culture)));
 }
        public string LogIn(string token, string email, string password, Culture culture = Culture.En)
        {
            if (!CheckToken(token))
            {
                return(null);
            }
            User user;//заглушка

            return(ToJson(SProcessResult.Convert(DataManager.Users.LogInUser(email, password, out user), culture)));
        }
        public string AddToBookmarks(int routeId)
        {
            User    user    = DefineUser(HttpContext);
            Culture culture = DefineLanguage(HttpContext);

            if (user == null)
            {
                return(ToJson(SProcessResult.Convert(ProcessResults.UserNotFound, culture)));
            }
            ProcessResult result = DataManager.Routes.AddBookmark(user.Id, routeId);

            return(ToJson(SProcessResult.Convert(result, culture)));
        }
Esempio n. 10
0
        public string AddComment(int placeId, string message)
        {
            var           user    = DefineUser(HttpContext);
            Culture       culture = DefineLanguage(HttpContext);
            ProcessResult result;

            if (user != null && user.HasUserAccess)
            {
                result = DataManager.Places.AddComment(placeId, user.Id, message);
            }
            else
            {
                result = ProcessResults.UserNotFound;
            }
            return(ToJson(SProcessResult.Convert(result, culture)));
        }
        public string Create(string name, string ids)
        {
            Culture culture = DefineLanguage(HttpContext);

            if (!HttpContext.Request.IsAjaxRequest())
            {
                return(ToJson(SProcessResult.Convert(ProcessResults.Error, culture)));
            }
            User          user        = DefineUser(HttpContext);
            var           places      = ids.Split(' ');
            var           translation = new Translation(name, name);
            ProcessResult result      = DataManager.Routes.CreateRoute(new Route {
                Author = user.Id, Translation = translation
            }, places);

            if (result.Succeeded)
            {
                CleanCookies();
            }
            return(ToJson(SProcessResult.Convert(result, culture)));
        }
        public string RemovePlaceFromChosen(string placeId)
        {
            if (!HttpContext.Request.IsAjaxRequest())
            {
                return(ToJson(SProcessResult.Convert(ProcessResults.Error)));
            }
            DefineLanguage(HttpContext);
            var places = GetChosenPlaces(HttpContext);

            if (!places.Any())
            {
                return(ToJson(new RouteProcessResult(false, false, Language.RouteEmpty)));
            }
            if (!places.Contains(placeId))
            {
                return(ToJson(new RouteProcessResult(false, false, Language.InvalidPlaceID)));
            }
            places.Remove(placeId);
            HttpContext.Response.SetCookie(SetChosenPlaces(places));
            return(ToJson(new RouteProcessResult(true, false, Language.PlaceRemovedSuccessfully)));
        }