Example #1
0
 public async Task <IActionResult> AddNotes(AddNotesRequestModel model)
 {
     try
     {
         if (model != null)
         {
             var userId = TokenUserId();
             if (await note.AddNotes(model, userId))
             {
                 return(Ok(new { success = true, Message = "Note added" }));
             }
             else
             {
                 return(BadRequest(new { success = false, Message = "Note did not added" }));
             }
         }
         else
         {
             return(BadRequest(new { success = false, Message = "Input should not be empty!!!" }));
         }
     }
     catch (Exception e)
     {
         return(BadRequest(new { success = false, e.Message }));
     }
 }
Example #2
0
 /// <summary>
 /// Adds the notes.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="userId">The user identifier.</param>
 /// <returns></returns>
 public async Task <bool> AddNotes(AddNotesRequestModel model, int userId)
 {
     try
     {
         return(await notes.AddNotes(model, userId));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #3
0
        /// <summary>
        /// Adds the notes.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="userId">The user identifier.</param>
        /// <returns></returns>
        public async Task <bool> AddNotes(AddNotesRequestModel model, int userId)
        {
            try
            {
                SqlConnection connection = DBConnection();
                SqlCommand    command    = StoreProcedureConnection("spAddNote", connection);
                command.Parameters.AddWithValue("Title", model.Title);
                command.Parameters.AddWithValue("MeassageDescription", model.Message);
                command.Parameters.AddWithValue("NoteImage", model.Image);
                command.Parameters.AddWithValue("Color", model.Color);
                command.Parameters.AddWithValue("CreatedDATETime", DateTime.Now);
                command.Parameters.AddWithValue("ModifiedDateTime", DateTime.Now);
                command.Parameters.AddWithValue("AddReminder", model.AddReminder);
                command.Parameters.AddWithValue("UserId", userId);
                command.Parameters.AddWithValue("IsPin", model.IsPin);
                command.Parameters.AddWithValue("IsNote", model.IsNote);
                command.Parameters.AddWithValue("IsArchive", model.IsArchive);
                command.Parameters.AddWithValue("IsTrash", model.IsTrash);
                connection.Open();
                int result = await command.ExecuteNonQueryAsync();

                connection.Close();
                if (result != 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                };
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #4
0
 public IActionResult CreateNotes(AddNotesRequestModel model)
 {
     return(Ok(note.CreateNotes(model)));
 }