Esempio n. 1
0
        private async Task ExecuteCreateCommand()
        {
            NewEventValidation newEventValidation = new NewEventValidation();

            if (newEventValidation.IsValid(Event))
            {
                Event.Direction.Add(EndLocation);
                Event.Direction.Insert(0, StartLocation);

                Event.EndPoints.Add(StartLocation);
                Event.EndPoints.Add(EndLocation);

                Event.Name  = $"{StartLocation.Name} - {EndLocation.Name}";
                Event.State = EventState.Formation;

                //User.Status = UserStatus.Organizer;
                //Event.Author = ( await _apiService.GetUserAsync ( Int32.Parse ( _secureStorage.GetValue ( "userId" ) ) ) ).Data as UserModel;

                //_secureStorage.SetValue ( "userStatus", UserStatus.Organizer.ToString () );

                var createdEvent = (await _apiService.CreateNewEventAsync(Event)).Data as EventModel;
                await _apiService.AddDirectionPointsAsync(createdEvent.Id, Event);

                createdEvent.CreatedTime = DateTime.Now;
                createdEvent.EventDate   = DateTime.Now;
                await _apiService.JoinEventAsync(createdEvent);

                _secureStorage.SetValue("eventId", createdEvent.Id.ToString());

                await NavigationService.NavigateAsync("../../../EventStatusOrganizerPage");
            }
            else
            {
                await UserDialogs.Instance.AlertAsync(newEventValidation.Message,
                                                      ResourcesForUserDialogs.ErrorTitle,
                                                      ResourcesForUserDialogs.OKButton);
            }
        }