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 })); } }
/// <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; } }
/// <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; } }
public IActionResult CreateNotes(AddNotesRequestModel model) { return(Ok(note.CreateNotes(model))); }