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)); }
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)); }
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)); }
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)); }