public void Setup()
 {
     _businessSafeSessionManager = new Mock<IBusinessSafeSessionManager>();
     _businessSafeSessionManager.Setup(x => x.CloseSession());
    _responsibilityTaskService = new Mock<IResponsibilityTaskService>();
     _completeViewModel = new CompleteResponsibilityTaskViewModel
                         {
                             CompanyId = 1234L,
                             CompletedComments = "comments",
                             ResponsibilityId = 4653L,
                             ResponsibilitySummary = new ResponsibilitySummaryViewModel
                                                     {
                                                         Description = "description",
                                                         Id = 45763L,
                                                         Title = "title"
                                                     },
                                                     ResponsibilityTask = new ViewResponsibilityTaskViewModel
                                                                          {
                                                                              ResponsibilityTaskId = _responsibilityTaskId
                                                                          },
                             ResponsibilityTaskId = _responsibilityTaskId
                         };
     _documentsToSaveViewModel = new DocumentsToSaveViewModel
                                 {
                                     CreateDocumentRequests = new List<CreateDocumentRequest>
                                                              {
                                                                  new CreateDocumentRequest() { }
                                                              },
                                     DeleteDocumentRequests = new List<long> { 1234L, 3573L }
                                 };
 }
        public CompleteResponsibilityTaskViewModel GetViewModel()
        {
            var task = _responsibilityTaskService.GetByIdAndCompanyId(_responsibilityTaskId, _companyId);

            var viewModel = new CompleteResponsibilityTaskViewModel
                       {
                           CompanyId = _companyId,
                           ResponsibilityTaskId = _responsibilityTaskId,
                           ResponsibilitySummary = new ResponsibilitySummaryViewModel
                                                       {
                                                           Id = task.Responsibility.Id,
                                                           Title = task.Responsibility.Title,
                                                           Description = task.Responsibility.Description
                                                       }
                       };

            viewModel.ResponsibilityTask = ViewResponsibilityTaskViewModel.CreateFrom(task);
            return viewModel;

        }
        public JsonResult Complete(CompleteResponsibilityTaskViewModel viewModel, DocumentsToSaveViewModel documentsToSaveViewModel)
        {
            if (!ModelState.IsValid)
            {
                throw new ArgumentException("Invalid Arguments To Complete Responsibility Task");
            }

            var request = new CompleteResponsibilityTaskRequest
                              {
                                  CompanyId = viewModel.CompanyId,
                                  ResponsibilityTaskId = viewModel.ResponsibilityTaskId,
                                  CompletedComments = viewModel.CompletedComments,
                                  UserId = CurrentUser.UserId,
                                  CreateDocumentRequests = documentsToSaveViewModel.CreateDocumentRequests,
                                  DocumentLibraryIdsToDelete = documentsToSaveViewModel.DeleteDocumentRequests,
                                  CompletedDate = DateTimeOffset.Now
                              };

            using (var session = _businessSafeSessionManager.Session)
            {
                _responsibilityTaskService.Complete(request);
                _businessSafeSessionManager.CloseSession();
            }

            using (var session = _businessSafeSessionManager.Session)
            {
                _responsibilityTaskService.SendTaskCompletedNotificationEmail(request);
                _businessSafeSessionManager.CloseSession();
            }

            return Json(new 
            {
                Success = true,
                Id = viewModel.ResponsibilityTaskId,
            });
        }