/// <summary> /// Colours the note. /// </summary> /// <param name="noteId">The note identifier.</param> /// <param name="userId">The user identifier.</param> /// <param name="colourRequest">The colour request.</param> /// <returns></returns> public async Task <bool> ColourNote(int noteId, int userId, ColourRequestModel colourRequest) { SqlConnection connection = DBConnection(); SqlCommand command = StoreProcedureConnection("spColour", connection); try { connection.Open(); command.Parameters.AddWithValue("@UserId", userId); command.Parameters.AddWithValue("@Id", noteId); command.Parameters.AddWithValue("@Color", colourRequest.Color); command.Parameters.AddWithValue("@ModifiedDateTime", DateTime.Now); int result = await command.ExecuteNonQueryAsync(); connection.Close(); if (result != 0) { return(true); } else { return(false); }; } catch (Exception e) { throw e; } }
public async Task <IActionResult> ColourNote(int noteId, ColourRequestModel colourRequest) { var userId = TokenUserId(); if (await note.ColourNote(noteId, userId, colourRequest)) { string status = "color changed successfully"; return(Ok(new { status, userId, noteId, colourRequest })); } else { string status = "color is not changed."; return(BadRequest(new { status, userId, noteId, colourRequest })); } }
/// <summary> /// Colours the note. /// </summary> /// <param name="noteId">The note identifier.</param> /// <param name="userId">The user identifier.</param> /// <param name="colourRequest">The colour request.</param> /// <returns></returns> public async Task <bool> ColourNote(int noteId, int userId, ColourRequestModel colourRequest) { return(await notes.ColourNote(noteId, userId, colourRequest)); }