public async Task <IActionResult> Create([Bind("Id,Name")] Specialization specialization)
        {
            if (ModelState.IsValid)
            {
                _context.Add(specialization);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(specialization));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,Location")] Institute institute)
        {
            if (ModelState.IsValid)
            {
                _context.Add(institute);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(institute));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("Name")] SubSpecialization subSpecialization, int specializationID)
        {
            if (ModelState.IsValid)
            {
                var specialization = _context.Specializations.FindAsync(specializationID).Result;
                subSpecialization.Specialization = specialization;

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

                return(RedirectToAction(nameof(Index), new { id = specializationID }));
            }
            return(View(subSpecialization));
        }
Example #4
0
        public async Task <IActionResult> Create([Bind("Name")] Department department, int facultyID)
        {
            if (ModelState.IsValid)
            {
                var faculty = _context.Faculties.FindAsync(facultyID).Result;
                department.Faculty = faculty;

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

                return(RedirectToAction(nameof(Index), new { id = facultyID }));
            }
            return(View(department));
        }
        public async Task <IActionResult> Create([Bind("id,SessionCreate,RegistrationExpired")] Session session)
        {
            if (ModelState.IsValid)
            {
                Random rand = new Random();

                session.id = DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString() + rand.Next(5000);
                _context.Add(session);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(session));
        }
Example #6
0
        public async Task <IActionResult> Create([Bind("Name")] Faculty faculty, int instituteID)
        {
            // int instituteID =(int) TempData["Data1"];

            if (ModelState.IsValid)
            {
                var institute = _context.Institutes.FindAsync(instituteID).Result;
                faculty.Institute = institute;

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

                return(RedirectToAction(nameof(Index), new { id = instituteID }));
            }
            return(View(faculty));
        }
        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));
        }
        public async Task <IActionResult> Registration(AdmissionApplication admissionApplication)
        {
            if (string.IsNullOrEmpty(admissionApplication.TraceId))
            {
                admissionApplication.TraceId = Guid.NewGuid().ToString();
            }

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

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

            //_fileUploaderService.UploadFile(admissionApplication.ProfilePicture, rootPath);
            //admissionApplication.ProfilePictureId = admissionApplication.ProfilePicture.FileName;

            //if (admissionApplication.ProfilePicture != null || admissionApplication.ProfilePicture.Length > 0)
            //{
            //    var profilePicturePath = Path.Combine(rootPath, admissionApplication.ProfilePicture.FileName);

            //    using (var stream = new FileStream(profilePicturePath, FileMode.Create))
            //    {
            //        await admissionApplication.ProfilePicture.CopyToAsync(stream);
            //        admissionApplication.ProfilePictureId = admissionApplication.ProfilePicture.FileName;
            //    }
            //}
            if (ModelState.IsValid || admissionApplication.IsDraft)
            {
                admissionApplication.IsDraft = true;
                await _context.AdmissionApplications.AddAsync(admissionApplication);

                await _context.SaveChangesAsync();

                //TODO : send mail to applicant

                return(RedirectToAction("AttachDocs", new { applicationTraceId = admissionApplication.TraceId }));
            }

            return(View());
        }