Exemplo n.º 1
0
        public async Task <JsonResult> UploadDocument(string id = null, string userType = null)
        {
            HttpFileCollectionBase files = Request.Files;
            HttpPostedFileBase     file  = files[0];

            string[] testfiles;
            string   fname = "";

            if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
            {
                testfiles = file.FileName.Split(new char[] { '\\' });
                fname     = testfiles[testfiles.Length - 1];
            }
            else
            {
                fname = file.FileName;
            }
            DocumentSubmissionViewModel obj = new DocumentSubmissionViewModel();

            obj = await service.GetById(Convert.ToInt32(id));

            obj.DocumentType = await serviceType.GetById(obj.DocumentTypeID.Value);

            obj.PhysicalFileLocaiton  = fname;
            obj.UserType              = userType;
            obj.DigitalPathofDocument = await service.UploadDocuments(obj);

            obj.onlinesubmitted = true;
            return(new JsonResult {
                Data = obj, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        /// <summary>
        /// Get data for Edit
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <JsonResult> GetDataToEdit(int id)
        {
            var record = await service.GetById(id);

            return(new JsonResult {
                Data = record, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public async Task <JsonResult> GetDocumentPermission(int userId = 0)
        {
            DocumentPortalViewModel        res          = new DocumentPortalViewModel();
            List <DocumentPermissionModel> documents    = null;
            List <MasterTableViewModel>    category     = new List <MasterTableViewModel>();
            List <MasterTableViewModel>    subCategory  = new List <MasterTableViewModel>();
            List <DocumentTypeViewModel>   documentType = new List <DocumentTypeViewModel>();

            List <int> categoryList     = new List <int>();
            List <int> subCategoryList  = new List <int>();
            List <int> documentTypeList = new List <int>();

            documents = await servicePortal.GetDocumentPermission(userId);

            if (documents.Count > 0)
            {
                foreach (var item in documents)
                {
                    if (item.CategoryID.HasValue)
                    {
                        categoryList.Add(item.CategoryID.Value);
                        category.Add(await serviceMaster.GetById(item.CategoryID.Value));
                    }
                    if (item.SubCategoryID.HasValue)
                    {
                        subCategoryList.Add(item.SubCategoryID.Value);
                        subCategory.Add(await serviceMaster.GetById(item.SubCategoryID.Value));
                    }
                    if (item.TypeID.HasValue)
                    {
                        documentTypeList.Add(item.TypeID.Value);
                        documentType.Add(await serviceType.GetById(item.TypeID.Value));
                    }
                }
            }

            foreach (var item in documentType)
            {
                if (!subCategoryList.Contains(item.DocumentCategoryID.Value))
                {
                    subCategory.Add(await serviceMaster.GetById(item.DocumentCategoryID.Value));
                }
            }

            res.Category    = category;
            res.SubCategory = subCategory;
            res.Type        = documentType;
            res.permission  = documents;
            return(new JsonResult {
                Data = res, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public async Task GetDocumentTypeById()
        {
            await _documentTypeService.GetById("id");

            _documentTypeRepositoryMock.Verify(c => c.GetByIdAsync(It.IsAny <string>()), Times.Once);
        }