Esempio n. 1
0
        public JsonResult GetSavedDocuments()
        {
            var saved_documents = _SubmittedDocumentService.GetAllAssigedToUser(_UserManager.GetUserId(User));

            return(Json(new
            {
                result = "Success",
                status_code = 200,
                my_documents = saved_documents
                               .OrderByDescending(e => e.DateLastModifiedUtc)
                               .OrderBy(e => e.IsCompleted)
                               .Select(e => new
                {
                    document_name = e.Name,
                    template_name = (e.Document != null) ? e.Document.Name : "",
                    submitted_document_id = e.IdSubmittedDocument,
                    last_modified_utc = e.DateLastModifiedUtc,
                    created_utc = e.DateCreatedUtc,
                    is_complete = e.IsCompleted
                })
            }));
        }
Esempio n. 2
0
        public async Task <JsonResult> Index()
        {
            if (User.Identity.IsAuthenticated)
            {
                var user = await _UserManager.GetUserAsync(User);

                List <SubmittedDocument> RequiresAttention = _SubmittedDocService.GetAllAssigedToUser(user.Id, true);
                DocumentFields           AwaitingFields    = _FieldService.GetAllAssignedFields(user.Id, true);

                return(Json(new
                {
                    result = "Success",

                    status_code = 200,

                    notification_count = RequiresAttention.Count,

                    awaiting_documents = RequiresAttention.Select(e => new
                    {
                        submitted_document_name = e.Name,
                        submitted_document_id = e.IdSubmittedDocument,
                        document_id = e.DocumentId,
                        assigned_by = (e.Assigner != null)? e.Assigner.Rank + " " + e.Assigner.FirstName + " " + e.Assigner.LastName : null,
                        date_assigned = e.DateCreatedUtc
                    }),

                    awaiting_signature = AwaitingFields.SignatureFields.Distinct().Select(e => new
                    {
                        submitted_document_name = e.SubmittedDocument.Name,
                        submitted_document_id = e.IdSubmittedDocumentId,
                        document_id = e.SubmittedDocument.DocumentId,
                        form_name = e.IdFormName
                    }),

                    awaiting_field_input = AwaitingFields.FormFields.Distinct().Select(e => new
                    {
                        submitted_document_name = e.SubmittedDocument.Name,
                        submitted_document_id = e.IdSubmittedDocumentId,
                        document_id = e.SubmittedDocument.DocumentId,
                        form_name = e.IdFormName
                    }),

                    awaiting_approval = AwaitingFields.CheckBoxes.Distinct().Select(e => new
                    {
                        submitted_document_name = e.SubmittedDocument.Name,
                        submitted_document_id = e.IdSubmittedDocumentId,
                        document_id = e.SubmittedDocument.DocumentId,
                        form_name = e.IdFormName
                    })
                }));
            }
            else
            {
                return(Json(new Result()
                {
                    reason = "User Not Autenticated",
                    result = "Failure",
                    status_code = 401
                }));
            }
        }