public async Task <IActionResult> PutRideComments([FromRoute] int id, [FromBody] RideComments rideComments) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != rideComments.Id) { return(BadRequest()); } _context.Entry(rideComments).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RideCommentsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostRideComments([FromBody] RideComments rideComments) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } rideComments.FullTime = DateTime.Now; _context.RideComments.Add(rideComments); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRideComments", new { id = rideComments.Id }, rideComments)); }
public RidePageViewModel(Ride ride, IPageService pageService) { _pageService = pageService; NewComment = new RideComments(); Ride = ride; if (Settings.StudentId == ride.DriverId) { IsInvitButtonVisible = false; } else { IsInvitButtonVisible = true; var initcond = GetIsSentInvitation(); } var url = "https://altaarefapp.azurewebsites.net/api/RideAttendants/ByRideId/" + Ride.Id; var results = _client.GetStringAsync(url); var list = JsonConvert.DeserializeObject <List <RideAttendants> >(results.Result); Attendants = list; if (Attendants.Count > 0) { IsAttendantsEmpty = false; } else { IsAttendantsEmpty = true; } NewComment = new RideComments { RideId = ride.Id, StudentId = Settings.StudentId }; var comments = GetComments(); if (ride.DriverId == Settings.StudentId) { IsDeleteButtonVisible = true; } else { IsDeleteButtonVisible = false; } }
private async Task AddComment() { if (NewComment.Comment == null) { return; } PostNewComment(); await GetComments(); NewComment = new RideComments { StudentId = Settings.StudentId, RideId = Ride.Id, Comment = "" }; }