Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,DisplayName,Description,PlaceId,GuideId,Price,Date,TimeInHours")] Trip trip)
        {
            if (getSessionUserType() != UserType.Admin)
            {
                Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                return(View("Error", new ErrorViewModel {
                    ErrorDescription = "אינך מורשה לגשת לעמוד זה"
                }));
            }

            trip.ID = Guid.NewGuid().ToString();

            if (ModelState.IsValid)
            {
                _context.Add(trip);
                await _context.SaveChangesAsync();

                string[] postMessage =
                {
                    trip.DisplayName,
                    "תיאור  הטיול: " + trip.Description,
                    "למידע נוסף והרשמה  לטיול: " + "https://localhost:5001/trip/Details/" + trip.ID
                };
                await FacebookApi.CreateFacebookPost(postMessage);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GuideId"] = new SelectList(_context.User, "Email", "FullName");
            ViewData["PlaceId"] = new SelectList(_context.Place, "ID", "Name");
            return(View(trip));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            var posts = await FacebookApi.GetPagePosts();

            var recommenedePlaces = CreatePlacesStatistics().Take(3);

            return(View(new HomeViewModel {
                FacebookPosts = posts, RecomendedPlaces = recommenedePlaces
            }));
        }