Exemple #1
0
        /// <summary>
        /// Edits the note.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="userId">The user identifier.</param>
        /// <returns></returns>
        public async Task <bool> EditNote(int noteId, EditNoteRequestModel model, int userId)
        {
            try
            {
                SqlConnection connection = DBConnection();
                SqlCommand    command    = StoreProcedureConnection("spEditNote", connection);
                connection.Open();
                command.Parameters.AddWithValue("Id", noteId);
                command.Parameters.AddWithValue("Title", model.Title);
                command.Parameters.AddWithValue("MeassageDescription", model.Message);
                command.Parameters.AddWithValue("AddReminder", model.Reminder);
                command.Parameters.AddWithValue("ModifiedDateTime", DateTime.Now);
                command.Parameters.AddWithValue("UserId", userId);
                int result = await command.ExecuteNonQueryAsync();

                connection.Close();
                if (result != 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                };
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #2
0
 public async Task <IActionResult> EditNote(int noteId, EditNoteRequestModel model)
 {
     if (noteId != 0 && (model.Message != null || model.Title != null))
     {
         var userId = TokenUserId();
         if (await note.EditNote(noteId, model, userId))
         {
             string status = "Note edited";
             return(Ok(new { status, userId, model }));
         }
         else
         {
             string status = "Note did not edited";
             return(BadRequest(new { status, userId, model }));
         }
     }
     else
     {
         return(BadRequest(new { success = false, Meassage = "Input should not be empty!!!" }));
     }
 }
Exemple #3
0
 /// <summary>
 /// Edits the note.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="userId">The user identifier.</param>
 /// <returns></returns>
 public async Task <bool> EditNote(int noteId, EditNoteRequestModel model, int userId)
 {
     return(await notes.EditNote(noteId, model, userId));
 }