public async Task <IActionResult> CreateEvent([FromBody] ClubEventCreateRequest clubEventCreateRequest) { await _clubEventsService.CreateEvent(clubEventCreateRequest); await _clubEventsService.SaveChangesAsync(); return(Ok()); }
private async void EditButton_Click(object sender, EventArgs e) { bool isValid = true; if (string.IsNullOrWhiteSpace(_title.Text)) { _title.Error = Literals.PleaseEnterTitle; isValid = false; } if (string.IsNullOrWhiteSpace(_description.Text)) { _description.Error = Literals.PleaseEnterDescription; isValid = false; } if (_markerPosition == null) { Toast.MakeText(this, Literals.PleaseEnterLocation, ToastLength.Long).Show(); isValid = false; } if (!isValid) { return; } var startTime = new DateTime( _startTimeDay.Year, _startTimeDay.Month + 1, // January-0 December-11 _startTimeDay.DayOfMonth, _startTimeHour.Hour, _startTimeHour.Minute, 0); ClubEventCreateRequest clubEventCreateRequest = new ClubEventCreateRequest { EventId = _clubEvent.Id, Title = _title.Text, Description = _description.Text, StartTime = startTime, EventType = (EventType)_eventTypesSpinner.SelectedItemPosition, Coordinates = _markerPosition }; AndHUD.Shared.Show(this, "Промяна на събитие…"); var response = await RestManager.EditClubEvent(clubEventCreateRequest); AndHUD.Shared.Dismiss(this); if (response.IsSuccessStatusCode) { Toast.MakeText(this, "Успешна промяна на събитие!", ToastLength.Short).Show(); } else { Toast.MakeText(this, "Неуспешна промяна на събитие!", ToastLength.Short).Show(); } }
public static async Task <HttpResponseMessage> EditClubEvent(ClubEventCreateRequest clubEventCreateRequest) { var jsonObject = JsonConvert.SerializeObject(clubEventCreateRequest); var content = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json"); return(await _httpClient.PostAsync( string.Format(ApiConstants.EditClubEventEndpoint, clubEventCreateRequest.EventId), content)); }
public async Task <IActionResult> EditEvent([FromRoute] int eventId, [FromBody] ClubEventCreateRequest clubEventCreateRequest) { bool isSuccess = await _clubEventsService.EditEvent(eventId, clubEventCreateRequest); if (isSuccess) { await _clubEventsService.SaveChangesAsync(); return(Ok()); } return(BadRequest()); }
public async Task <bool> EditEvent(int eventId, ClubEventCreateRequest clubEventCreateRequest) { var clubEvent = await _clubEventsRepository.GetById(eventId); if (clubEvent == null) { return(false); } clubEvent.Title = clubEventCreateRequest.Title; clubEvent.Description = clubEventCreateRequest.Description; clubEvent.EventType = clubEventCreateRequest.EventType; clubEvent.Latitude = clubEventCreateRequest.Coordinates.Latitude; clubEvent.Longtitude = clubEventCreateRequest.Coordinates.Longtitute; clubEvent.StartTime = clubEventCreateRequest.StartTime; _clubEventsRepository.UpdateEvent(clubEvent); return(true); }
public async Task CreateEvent(ClubEventCreateRequest clubEventCreateRequest) { Club club = await _clubsRepository.GetClubById(clubEventCreateRequest.ClubId); if (club == null) { return; } ClubEvent clubEvent = new ClubEvent { Club = club, Title = clubEventCreateRequest.Title, Description = clubEventCreateRequest.Description, EventType = clubEventCreateRequest.EventType, StartTime = clubEventCreateRequest.StartTime, Longtitude = clubEventCreateRequest.Coordinates.Longtitute, Latitude = clubEventCreateRequest.Coordinates.Latitude }; if (clubEventCreateRequest.IncludePlayerStatuses == PlayerStatus.All) { foreach (var member in club.Members) { clubEvent.InvitedMembers.Add(new ClubEventMember { ClubEvent = clubEvent, Member = member }); } } else { // clubEvent.InvitedMembers.Where(im => im IN IncludePlayerStatuses) = club.Members, TODO Implement individual events } _clubEventsRepository.AddEvent(clubEvent); }
private async void CreateButton_Click(object sender, System.EventArgs e) { var title = FindViewById <EditText>(Resource.Id.et_createClubEvent_clubEventTitle); var description = FindViewById <EditText>(Resource.Id.et_createClubEvent_clubEventDescription); bool isValid = true; if (string.IsNullOrWhiteSpace(title.Text)) { title.Error = Literals.PleaseEnterTitle; isValid = false; } if (string.IsNullOrWhiteSpace(description.Text)) { description.Error = Literals.PleaseEnterDescription; isValid = false; } if (_markerPosition == null) { Toast.MakeText(this, Literals.PleaseEnterLocation, ToastLength.Long).Show(); isValid = false; } if (!isValid) { return; } var clubId = Intent.GetIntExtra("clubId", 0); var startTime = new DateTime( _startTimeDay.Year, _startTimeDay.Month + 1, // January-0 December-11 _startTimeDay.DayOfMonth, _startTimeHour.Hour, _startTimeHour.Minute, 0); ClubEventCreateRequest clubEventCreateRequest = new ClubEventCreateRequest { ClubId = clubId, Title = title.Text, Description = description.Text, StartTime = startTime, EventType = (EventType)_eventTypesSpinner.SelectedItemPosition, Coordinates = _markerPosition }; AndHUD.Shared.Show(this, "Създаване на събитие…"); var response = await RestManager.CreateClubEvent(clubEventCreateRequest); AndHUD.Shared.Dismiss(this); if (response.IsSuccessStatusCode) { Toast.MakeText(this, "Успешно създадено събитие!", ToastLength.Short).Show(); //var intent = new Intent(this, typeof(ClubEventsFragment)); //StartActivity(intent); } else { Toast.MakeText(this, "Неуспешно създадено събитие!", ToastLength.Short).Show(); } }