public IActionResult CreateThesis(string thesisSubjectCreate, int specialityType, int degreeCycle) { if (string.IsNullOrEmpty(thesisSubjectCreate)) { TempData["Error"] = "Temat nie może być pusty"; return(RedirectToAction("Theses", "SupervisorHome")); } if (!AuthenticationController.IsUserAuthorized(HttpContext, AuthenticationController.UserRole.Supervisor)) { return(RedirectToAction("NotAuthorized", "Authentication")); } var userId = HttpContext.Session.GetInt32("UserId"); var sup = _context.Supervisors .FirstOrDefault(s => s.UserId == userId); var thes = new Thesis { Subject = thesisSubjectCreate, DegreeCycle = degreeCycle, SpecId = specialityType, SuperId = sup.Id, StudentId = null }; _context.Add(thes); _context.SaveChanges(); TempData["Success"] = "Nowy temat został dodany"; return(RedirectToAction("Theses", "SupervisorHome")); }
public IActionResult CreateThesis(int supersId, string thesisSubject) { if (!AuthenticationController.IsUserAuthorized(HttpContext, AuthenticationController.UserRole.Student)) { return(RedirectToAction("NotAuthorized", "Authentication")); } var userId = HttpContext.Session.GetInt32("UserId"); var stud = _context.Students .FirstOrDefault(s => s.UserId == userId); var thesis = new Thesis { Subject = thesisSubject, DegreeCycle = stud.DegreeCycle, SpecId = stud.SpecialtyId, SuperId = supersId, StudentId = stud.Id }; _context.Add(thesis); _context.SaveChanges(); return(RedirectToAction("Index", "StudentHome")); }