public RestAPIDeleteIdeaResponse DeleteIdeaComment(ResponseBase response, int IdeaCommentId)
        {
            RestAPIDeleteIdeaResponse restAPIDeleteIdeaResponse = new RestAPIDeleteIdeaResponse();

            DatabaseWrapper.databaseOperation(response,
                                              (context, query) =>
            {
                IdeaComment ideaComment = query.GetIdeaCommentById(context, IdeaCommentId);

                if (ideaComment != null)
                {
                    query.DeleteIdeaComment(context, ideaComment);
                    response.Status = Success;
                }
                else
                {
                    response.ErrorList.Add(Faults.IdeaCommentNotFound);
                    response.Status = Failure;
                    return;
                }

                context.SubmitChanges();
            }
                                              , readOnly: false
                                              );

            if (response == null && response.ErrorList.Count != 0)
            {
                response.ErrorList.Add(Faults.ServerIsBusy);
                restAPIDeleteIdeaResponse.ErrorList = response.ErrorList;
            }

            return(restAPIDeleteIdeaResponse);
        }
        public RestAPIDeleteIdeaResponse DeleteIdeaComment([FromUri] int IdeaCommentId)
        {
            RestAPIDeleteIdeaResponse response = new RestAPIDeleteIdeaResponse();

            submitIdeaUtil.DeleteIdeaComment(response, IdeaCommentId);

            return(response);
        }
Example #3
0
        public void DeleteIdeaCommentsTest()
        {
            RestAPIDeleteIdeaResponse response = new RestAPIDeleteIdeaResponse();
            IdeaComment ideaComment            = new IdeaComment();
            int         IdeaCommentId          = 1;

            queryUtilMock.Setup(x => x.GetIdeaCommentById(It.IsAny <IIdeaDatabaseDataContext>(), It.IsAny <int>())).Returns(ideaComment);
            submitIdeaMock.Setup(x => x.DeleteIdeaComment(It.IsAny <RestAPIDeleteIdeaResponse>(), It.IsAny <int>()));
            submitIdeaUtil.DeleteIdeaComment(response, IdeaCommentId);

            Assert.IsTrue(response.ErrorList.Count == 0);
        }
Example #4
0
        public void DeleteIdeaCommentTest()
        {
            RESTAPIIdeaController apiController = new RESTAPIIdeaController()
            {
                DeviceWithDbContext = new RESTAPIDeviceWithDbContext()
                {
                    DbContext = new IdeaDatabase.DataContext.IdeaDatabaseDataContext()
                }
            };
            RestAPIDeleteIdeaResponse response = new RestAPIDeleteIdeaResponse();
            int IdeaId = 1;

            Assert.IsNotNull(apiController.DeleteIdeaComment(IdeaId));
            submitIdeaMock.Verify(x => x.DeleteIdeaComment(It.IsAny <RestAPIDeleteIdeaResponse>(), It.IsAny <int>()));
        }