コード例 #1
0
        public async Task <IActionResult> UpdateNotes(NotesModel notesModel, int id)
        {
            try
            {
                if (!notesModel.Equals(null) && !id.Equals(null))
                {
                    ////BusinessLayer method call
                    var result = await this._businessManager.UpdateNotes(notesModel, id);

                    ////check the result is not null
                    if (!result.Equals(null))
                    {
                        ////return the success result.
                        return(this.Ok(new { result }));
                    }
                    else
                    {
                        ////throw the exception message
                        return(this.BadRequest(new { Message = "The notes are not successfuly updated" }));
                    }
                }
                else
                {
                    ////throw the exception message
                    return(this.BadRequest(new { Message = "The note model or note id is invalid" }));
                }
            }
            catch (Exception ex)
            {
                ////throw the exception message
                throw new Exception(ex.Message);
            }
        }
コード例 #2
0
        /// <summary>
        /// update the collaborator data.
        /// </summary>
        /// <param name="noteId">note id</param>
        /// <param name="id">collaborator id.</param>
        /// <param name="notesModel">notes model data.</param>
        /// <returns>return the result.</returns>
        public async Task <int> UpdateCollaborator(int noteId, int id, NotesModel notesModel)
        {
            try
            {
                if (!notesModel.Equals(null) && !id.Equals(null) && !noteId.Equals(null))
                {
                    ////repositoryManager Layer method.
                    var result = await this.repositoryManager.UpdateCollaborator(noteId, id, notesModel);

                    if (!result.Equals(null))
                    {
                        return(result);
                    }
                    else
                    {
                        throw new Exception("collaborator is not successfully updated");
                    }
                }
                else
                {
                    throw new Exception("note id or collaborator id or notes model data are null");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }