コード例 #1
0
    /// <summary>
    /// Save a comment
    /// Exception:PrimaryKeyException, SqlException, Exception
    /// PrimaryKeyException:When trying to insert data in DB with existing primary key
    /// </summary>
    /// <param name="commentObj">commentObj</param>
    /// <returns>save status</returns>
    public string SaveComment(Comment commentObj)
    {
        bool isSaved = false;

        try
        {
            CommentGateway commentGatewayObj = new CommentGateway();
            isSaved = commentGatewayObj.InsertComment(commentObj);
        }
        catch (PrimaryKeyException primaryKeyExceptionObject)
        {
            throw primaryKeyExceptionObject;
        }
        catch (SqlException sqlExceptionObj)
        {
            throw sqlExceptionObj;
        }
        catch (Exception exceptionObj)
        {
            throw exceptionObj;
        }


        if (isSaved)
        {
            return("Comment is saved");
        }
        else
        {
            return("Comment is not saved");
        }
    }
コード例 #2
0
 /// <summary>
 /// Select all comments of a task
 /// Exception:SqlException, Exception
 /// </summary>
 /// <param name="taskId">task id</param>
 /// <returns>List of all comments of the task</returns>
 public List <Comment> GetCommentsOfTheTask(string taskId)
 {
     try
     {
         CommentGateway commentGatewayObj = new CommentGateway();
         return(commentGatewayObj.SelectAllCommentsOfTheTask(taskId));
     }
     catch (SqlException sqlExceptionObj)
     {
         throw sqlExceptionObj;
     }
     catch (Exception exceptionObj)
     {
         throw exceptionObj;
     }
 }
コード例 #3
0
 public CommentManager()
 {
     commentGateway = new CommentGateway();
 }
コード例 #4
0
ファイル: CommentController.cs プロジェクト: sirina26/WP
 public CommentController(CommentGateway commentGateway)
 {
     _commentGateway = commentGateway;
 }