public async Task <IActionResult> RegistrationDocs(AttachmentViewModel attachmentViewModel, string applicationTraceId)
        {
            var fileCategory = Request.Form["FileCategory"];
            var rootPath     = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\documents", applicationTraceId);

            if (!Directory.Exists(rootPath))
            {
                Directory.CreateDirectory(rootPath);
            }



            var admissionApplication = _context.AdmissionApplications.Where(p => p.TraceId == applicationTraceId).Single();
            int i = 0;

            foreach (var attachment in attachmentViewModel.ApplicationAttachmentFiles)
            {
                _fileService.UploadFile(attachment, rootPath);
                admissionApplication.ApplicationAttachments.Add(new ApplicationAttachment {
                    FileName = attachment.FileName, FileCategory = fileCategory[i], AdmissionApplication = admissionApplication
                });
                i++;
            }
            _context.Update(admissionApplication);
            await _context.SaveChangesAsync();

            return(RedirectToAction("AttachDocs", new { applicationTraceId = applicationTraceId }));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Institute,Faculty,Department,Designation,Phone,Email,Specialization,SubSpecialization,Photo,ResearchAreas")] ResourcePerson resourcePerson, ICollection <string> ResearchAreas)
        {
            if (ModelState.IsValid)
            {
                var traceId  = Guid.NewGuid().ToString();
                var rootPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\documents\\ResourcePerson", traceId);

                if (!Directory.Exists(rootPath))
                {
                    Directory.CreateDirectory(rootPath);
                }

                if (resourcePerson.Photo != null && resourcePerson.Photo.Length > 0)
                {
                    _fileService.UploadFile(resourcePerson.Photo, rootPath);
                    resourcePerson.PicFolderId   = traceId;
                    resourcePerson.PhotoFileName = resourcePerson.Photo.FileName;
                }

                foreach (string item in ResearchAreas)
                {
                    int value = 0;
                    if (int.TryParse(item, out value))
                    {
                        resourcePerson.ResearchAreas.Add(new ResearchArea {
                            ResearchInterestId = value
                        });
                    }
                    else
                    {
                        resourcePerson.ResearchAreas.Add(new ResearchArea {
                            ResearchInterest = new ResearchInterest {
                                AreaName = item
                            }
                        });
                    }
                }

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

                return(RedirectToAction(nameof(Index)));
            }
            return(View(resourcePerson));
        }