Exemple #1
0
        public async Task <IActionResult> Create([Bind("Id,FilePath,FileName,DocumentTypeId,Comments,MyFiles,LearnerId,CompanyId,Verified,VerificationDate,VerifiedBy,JobApplicationId,CreatedBy,DateCreated,LastUpdatedBy,DateUpdated")] Document document)
        {
            if (ModelState.IsValid)
            {
                //Get current user details
                var user = await _lookUpService.GetCurrentLoggedInUser(User.Identity.Name);

                //Get current leaner details
                var learner = await _lookUpService.GetLearnerDetailsByIdEmail(user.Person.NationalId);

                //assign Leaner Id to link these qualifications to leaner
                document.LearnerId = learner.LearnerId;

                document.FileName = document.MyFiles.FileName;
                if (document.DocumentTypeId != null)
                {
                    document.FilePath = _foldersConfigation.Documents + learner.NationalID + "/" +
                                        (_lookUpService.GetAllDocumentTypesById(document.DocumentTypeId).Result
                                         .TypeName);
                }
                _fileService.UploadFile(document.MyFiles, document.FilePath);

                //create an audit trail
                document.CreatedBy     = user.UserName;
                document.DateCreated   = DateTime.Now.Date;
                document.LastUpdatedBy = user.UserName;
                document.DateUpdated   = DateTime.Now.Date;
                document.Verified      = "false";
                document.FilePath      = _foldersConfigation.Documents + learner.NationalID + "/" +
                                         (_lookUpService.GetAllDocumentTypesById(document.DocumentTypeId).Result
                                          .TypeName) + "/";

                _context.Add(document);
                await _context.SaveChangesAsync();

                _notyf.Success("Document created successfully....");

                return(RedirectToAction("Details", "Person", new { id = learner.NationalID }));
            }

            return(PartialView(document));
        }
        // GET: DocumentTypes/Details/5
        public async Task <IActionResult> Details(Guid id)
        {
            var documentTypesDetails = await _lookUpService.GetAllDocumentTypesById(id);

            if (documentTypesDetails == null)
            {
                return(NotFound());
            }

            return(PartialView(documentTypesDetails));
        }