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 }));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] SubSpecialization subSpecialization, int specializationID)
        {
            if (id != subSpecialization.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subSpecialization);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubSpecializationExists(subSpecialization.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { id = specializationID }));
            }
            return(View(subSpecialization));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("id,Name")] Department department, int facultyID)
        {
            if (id != department.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(department);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(department.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { id = facultyID }));
            }
            return(View(department));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(string id, [Bind("id,SessionCreate,RegistrationExpired")] Session session)
        {
            if (id != session.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(session);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SessionExists(session.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(session));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Location")] Institute institute)
        {
            if (id != institute.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(institute);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstituteExists(institute.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(institute));
        }
Esempio n. 6
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] Faculty faculty, int instituteID)
        {
            if (id != faculty.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(faculty);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FacultyExists(faculty.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }



                return(RedirectToAction(nameof(Index), new { id = instituteID }));
            }
            return(View(faculty));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Institute,Faculty,Department,Designation,Phone,Email,Specialization,SubSpecialization,Photo")] ResourcePerson resourcePerson, string pid, string FileName)
        {
            if (id != resourcePerson.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                //var traceId = Guid.NewGuid().ToString();

                // var temp = await _context.ResourcePerson.FindAsync(id);

                //if(resourcePerson.Institute==null)
                //{
                //    resourcePerson.Faculty = null;
                //    resourcePerson.Department = null;
                //}
                //if (resourcePerson.Faculty == null)
                //{
                //    resourcePerson.Department = null;
                //}
                //if(resourcePerson.Specialization==null)
                //{
                //    resourcePerson.SubSpecialization = null;
                //}

                if (pid == null)
                {
                    pid = Guid.NewGuid().ToString();
                }

                var rootPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\documents\\ResourcePerson", pid);

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


                if (resourcePerson.Photo != null && resourcePerson.Photo.Length > 0)
                {
                    _fileService.UploadFile(resourcePerson.Photo, rootPath);

                    string temp = rootPath + "\\" + FileName;

                    _fileService.RemoveFile(temp);


                    resourcePerson.PhotoFileName = resourcePerson.Photo.FileName;
                    resourcePerson.PicFolderId   = pid;
                }
                else
                {
                    resourcePerson.PhotoFileName = FileName;
                    resourcePerson.PicFolderId   = pid;
                }


                try
                {
                    _context.Update(resourcePerson);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ResourcePersonExists(resourcePerson.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(resourcePerson));
        }