public IActionResult Delete(AppreciationKeyFromModel model) { var appreciation = _context.Appreciations.FirstOrDefault(a => a.ApplicationUserID == model.ApplicationUserID && a.DestinationID == model.DestinationID); if (appreciation == null) { return(NotFound()); } _context.Appreciations.Remove(appreciation); _context.SaveChanges(); return(NoContent()); }
public IActionResult Put(AppreciationKeyFromModel key, [FromBody] Appreciation model) { if (key.ApplicationUserID != model.ApplicationUserID || key.DestinationID != model.DestinationID) { return(BadRequest()); } var appreciation = _context.Appreciations.FirstOrDefault(a => a.ApplicationUserID == model.ApplicationUserID && a.DestinationID == model.DestinationID); if (appreciation == null) { return(NotFound()); } appreciation.Content = model.Content; appreciation.Rating = model.Rating; appreciation.CreateDate = model.CreateDate; _context.Appreciations.Update(appreciation); _context.SaveChanges(); return(NoContent()); }
public IActionResult Get(AppreciationKeyFromModel model) { var appreciation = _context.Appreciations.FirstOrDefault(a => a.ApplicationUserID == model.ApplicationUserID && a.DestinationID == model.DestinationID); return(Ok(appreciation)); }