public async Task <IActionResult> UpdateFavourite(int id, [FromBody] MstFavourites mstFavourites) { try { if (mstFavourites != null && id != 0) { using (EzyFind_DevContext db = new EzyFind_DevContext()) { db.MstFavourites.Update(mstFavourites); await db.SaveChangesAsync(); id = mstFavourites.MstFavouriteId; } response.Status = true; // Operation Status Indicator response.Message = "Successful: Favourite updated"; // Exception Message response.Result = id; return(Ok(response)); } else { response.Status = false; // Operation Status Indicator response.Message = "Warning : No Favourite provided"; // Exception Message response.Result = null; return(Ok(response)); } } catch { response.Status = false; // Operation Status Indicator response.Message = "Error : Unable to update Favourite"; // Exception Message response.Result = null; return(Ok(response)); } }
public async Task <IActionResult> PutMstFavourites([FromRoute] int id, [FromBody] MstFavourites mstFavourites) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mstFavourites.MstFavouriteId) { return(BadRequest()); } _context.Entry(mstFavourites).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MstFavouritesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostMstFavourites([FromBody] MstFavourites mstFavourites) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.MstFavourites.Add(mstFavourites); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMstFavourites", new { id = mstFavourites.MstFavouriteId }, mstFavourites)); }