private async Task <bool> PostRideAttendant(RidesInvitations UpdatedRideInvitaion) { var postUrl = "https://altaarefapp.azurewebsites.net/api/RideAttendants/"; RideAttendants rideAttendants = new RideAttendants { AttendantId = UpdatedRideInvitaion.CandidateId, RideId = UpdatedRideInvitaion.RideId }; var content = new StringContent(JsonConvert.SerializeObject(rideAttendants), Encoding.UTF8, "application/json"); var response = _client.PostAsync(postUrl, content); var insertedRes = await response.Result.Content.ReadAsStringAsync(); if (response.Result.IsSuccessStatusCode) { //await FCMPushNotificationSender.Send( // "SG" + StudyGroup.CourseId, // "New Study Group", // "New study group added in a course you interested in, join now!"); return(true); } else { await _pageService.DisplayAlert("Error", "Something went wrong", "OK", "Cancel"); return(false); } }
public async Task <IActionResult> PostRideAttendants([FromBody] RideAttendants rideAttendants) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.RideAttendants.Add(rideAttendants); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (RideAttendantsExists(rideAttendants.RideId, rideAttendants.AttendantId)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetRideAttendants", new { id = rideAttendants.RideId }, rideAttendants)); }
public async Task <IActionResult> PutRideAttendants([FromRoute] int AttendantId, [FromRoute] int RideId, [FromBody] RideAttendants rideAttendants) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (RideId != rideAttendants.RideId && AttendantId != rideAttendants.AttendantId) { return(BadRequest()); } _context.Entry(rideAttendants).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RideAttendantsExists(RideId, AttendantId)) { return(NotFound()); } else { throw; } } return(NoContent()); }