public async Task <IActionResult> PutIceCream(long id, IceCream iceCream) { if (id != iceCream.Id) { return(BadRequest()); } _context.Entry(iceCream).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!IceCreamExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("StudentID,FirstName,LastName,InstructorID")] StudentM student) { //TODO: Need ref. to Instructor TD from Login Instructor// if (ModelState.IsValid) { _context.Add(student); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(student)); }
public async Task <IActionResult> Create([Bind("StudentID,FirstName,LastName,InstructorID")] StudentM student) { //TODO: Need ref. to Instructor TD from Login Instructor// if (ModelState.IsValid) { if (HttpContext.Session.GetInt32(SessionLoggedID) != null) { var PassID = HttpContext.Session.GetInt32(SessionLoggedID); student.InstructorID = (int)PassID; _context.Add(student); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } } ViewBag.Error("An Error Occured, Please Re-Log into your account"); return(RedirectToAction("Logout", "Instructors")); }
public async Task <IActionResult> InstructorRegister([Bind("ID,LastName,FirstName,UserName,Password,Email")] InstructorM instructor) { bool find = _context.Instructors.ToList().Any(m => m.UserName == instructor.UserName); if (find) { ViewBag.Error = "User Name already exists, Please choose a different User Name"; instructor.UserName = ""; return(View()); } else if (ModelState.IsValid) { ViewBag.success = instructor.FirstName + " Your Account Has Been Succesfully Created!"; _context.Add(instructor); await _context.SaveChangesAsync(); ModelState.Clear(); return(View("InstructorLogin")); } return(View(instructor)); }