Esempio n. 1
0
        public async Task <IActionResult> GetDocumentCounts([FromBody] SearchRequestVM searchRequestVM)
        {
            try
            {
                GenericResponseVM genericResponse = null;
                #region Error Checking
                //Input validation
                if (searchRequestVM == null && searchRequestVM.Client == null && searchRequestVM.SearchObject == null)
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value   = errorSettings.MessageNoInputs,
                        Code    = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
                }
                #endregion
                //For a given search request entered by the user, this api will get all documents that has been
                //uploaded by him, all documents that are assigned to him and all the documents which are pinned by him
                int allDocumentCounts = await documentProvision.GetAllCounts(searchRequestVM);

                int myDocumentCounts = await documentProvision.GetMyCounts(searchRequestVM);

                int pinnedDocumentCounts = await documentProvision.GetPinnedCounts(searchRequestVM);

                //The object count information that will be sent to the user
                var documentCounts = new
                {
                    AllDocumentCounts    = allDocumentCounts,
                    MyDocumentCounts     = myDocumentCounts,
                    PinnedDocumentCounts = pinnedDocumentCounts,
                };
                //If the input validation is failed, send GenericResponseVM which contains the error information
                return(matterCenterServiceFunctions.ServiceResponse(documentCounts, (int)HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }