public ActionResult Create([Bind(Include = "ID,Year,NameOfClass,Roll,Name,Email,Cell")] AllTheStudent allTheStudent) { if (ModelState.IsValid) { db.AllTheStudents.Add(allTheStudent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(allTheStudent)); }
public ActionResult Create([Bind(Include = "id,program_code,program_title,course_code,course_title,course_hours,section_number,have_final_exam,final_exam_note,room_request,exam_length,weekday,time,room,teacher_name,proctor,is_deleted,created_by,created_on,modified_by,modified_on")] special_arrangement special_arrangement) { if (ModelState.IsValid) { db.special_arrangement.Add(special_arrangement); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(special_arrangement)); }
public ActionResult Create(TableExam exam) { if (ModelState.IsValid) { exam.status = "up coming"; db.TableExams.Add(exam); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(exam)); }
public ActionResult Create([Bind(Include = "ClassRoom1,NameTeacher")] ClassRoom classRoom) { if (ModelState.IsValid) { db.ClassRooms.Add(classRoom); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(classRoom)); }
public string ActivatePicture(int id, string path) { string a = "1"; Students st = (from s in _context.Students where s.StudentId == id select s).First(); st.Picture = path; _context.SaveChanges(); return(a); }
public ActionResult Create([Bind(Include = "ID,Roll,Name,Email,Cell")] ClassSevenStudent classSevenStudent) { if (ModelState.IsValid) { db.ClassSevenStudents.Add(classSevenStudent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(classSevenStudent)); }
public ActionResult Create([Bind(Include = "ID,Name,Email,Cell,NameOfClass,Subject")] AllTheTeacher allTheTeacher) { if (ModelState.IsValid) { db.AllTheTeachers.Add(allTheTeacher); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(allTheTeacher)); }
public ActionResult Create([Bind(Include = "ID,CourseName,CourseTeacher,CourseOfClass,Division")] AllTheCourse allTheCourse) { if (ModelState.IsValid) { db.AllTheCourses.Add(allTheCourse); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(allTheCourse)); }
public IActionResult create([FromBody] Exam item) { if (item == null) { return(BadRequest()); } _context.ExamItems.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetExam", new { id = item.Id }, item)); }
public ActionResult Create([Bind(Include = "id,program_code,title,is_deleted,created_by,created_on,modified_by,modified_on")] program program) { if (ModelState.IsValid) { program.created_on = DateTime.Now; db.programs.Add(program); db.SaveChanges(); return RedirectToAction("Index"); } return View(program); }
public ActionResult Create([Bind(Include = "id,employee_id,first_name,middle_name,last_name,gender,birthdate,e_mail,mobile_number,work_number,is_deleted,created_by,created_on,modified_by,modified_on")] faculty faculty) { if (ModelState.IsValid) { faculty.created_on = DateTime.Now; db.faculties.Add(faculty); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(faculty)); }
public ActionResult AddDers(Ders Ders) { Ders yeni = new Ders(); yeni.Kod = Ders.Kod; yeni.Name = Ders.Name; yeni.Number = Ders.Number; yeni.TeacherName = Ders.TeacherName; yeni.TeacherSurname = Ders.TeacherSurname; db.Dersler.Add(yeni); db.SaveChanges(); return(View("Index")); }
public ActionResult Create([Bind(Include = "id,name,capacity,room_type_id,is_deleted,created_by,created_on,modified_by,modified_on")] room room) { if (ModelState.IsValid) { room.created_on = DateTime.Now; db.rooms.Add(room); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.room_type_id = new SelectList(db.room_type, "id", "type", room.room_type_id); return(View(room)); }
public ActionResult Create([Bind(Include = "id,user01,passwork,email,phone,0")] User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Create([Bind(Include = "id,type,is_deleted,created_by,created_on,modified_by,modified_on")] room_type room_type) { if (ModelState.IsValid) { room_type.is_deleted = false; room_type.created_on = DateTime.Now; db.room_type.Add(room_type); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(room_type)); }
public ActionResult Create(Exam exam) { try { db.Exams.Add(exam); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View(exam)); } }
public IActionResult Register(UserViewModel model) { User CheckUser = _context.Users.SingleOrDefault(User => User.Email == model.Email); if (CheckUser != null) { ViewBag.Err = "Email already exists"; } else if (ModelState.IsValid) { PasswordHasher <User> Hasher = new PasswordHasher <User>(); User NewUser = new User(); NewUser.FirstName = model.FirstName; NewUser.LastName = model.LastName; NewUser.Email = model.Email; NewUser.Password = Hasher.HashPassword(NewUser, model.Password); NewUser.CreatedAt = DateTime.Now; NewUser.UpdatedAt = DateTime.Now; _context.Users.Add(NewUser); _context.SaveChanges(); User LoggedUser = _context.Users.SingleOrDefault(user => user.Email == model.Email); HttpContext.Session.SetInt32("UserId", LoggedUser.UserID); return(RedirectToAction("Dashboard", "Dashboard")); } return(View("Index")); }
// HANDLER for POST requests public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } var schoolClass = _db.SchoolClasses.FirstOrDefault(s => s.Guid == StudentDto.SchoolClassGuid); if (schoolClass is null) { ModelState.AddModelError(nameof(App.Dtos.StudentDto.SchoolClassGuid), "Class not knwon."); return(Page()); } var student = _mapper.Map <StudentDto, Student>(StudentDto, opt => opt.AfterMap((src, dst) => { dst.SchoolClass = schoolClass; })); _db.Students.Add(student); // INSERT INTO _db.SaveChanges(); // REDIRECT AFTER POST //return Page(); return(RedirectToPage("/Students/Index")); }
public IActionResult AddUserToDB(RegisterViewModel model) { if (ModelState.IsValid) { List <User> CheckEmail = _context.UserTable.Where(theuser => theuser.Email == model.Email).ToList(); if (CheckEmail.Count > 0) { ViewBag.ErrorRegister = "Email already in use..."; return(View("Index")); } User newuser = new User() { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Password = model.Password, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }; _context.UserTable.Add(newuser); _context.SaveChanges(); User JustCreated = _context.UserTable.SingleOrDefault(theUser => theUser.Email == model.Email); HttpContext.Session.SetInt32("UserId", (int)JustCreated.UserId); HttpContext.Session.SetString("UserName", (string)JustCreated.FirstName + " " + (string)JustCreated.LastName); return(RedirectToAction("dashboard", "Activity"));// eto kogda mi hotim prosto sdelat refresh // return View("success"); //eto kogda mi hotim postroit stranicu zanovo, uvidet formu, dlya registration in dlya login } else { // ViewBag.errors=ModelState.Values; return(View("Index")); } }
public IActionResult Register(RegisterViewModel model) { if (_context.users.Where(u => u.email == model.email).SingleOrDefault() != null) { TempData["message"] = "Email is taken!"; return(RedirectToAction("Index")); } else { if (ModelState.IsValid) { User NewUser = new User { first_name = model.first_name, last_name = model.last_name, email = model.email, password = model.password }; NewUser.created_at = DateTime.Now; NewUser.updated_at = DateTime.Now; _context.Add(NewUser); _context.SaveChanges(); User current = _context.users.Where(u => u.email == model.email).SingleOrDefault(); HttpContext.Session.SetInt32("UserId", current.id); TempData["message"] = "You have successfully registered!"; return(RedirectToAction("Activity", "Activity")); } ViewBag.Errors = ModelState.Values; ViewBag.Status = true; return(View("Index")); } }
public ActionResult Create([Bind(Include = "id,course_id,have_final_exam,exam_length,required_room_type_id,final_exam_note,is_deleted,created_by,created_on,modified_by,modified_on")] course_exam course_exam) { if (ModelState.IsValid) { course_exam.created_on = DateTime.Now; db.course_exam.Add(course_exam); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.required_room_type_id = new SelectList(db.room_type.Where(r => r.is_deleted == false), "id", "type", course_exam.required_room_type_id); ViewBag.course_id = new SelectList(db.courses.Where(p => !(db.course_exam.Any(p2 => p2.course_id == p.id)) && p.is_deleted == false).OrderBy(o => o.code), "id", "courseDropdown", course_exam.course_id); return(View(course_exam)); }
public ActionResult Create(Exam exam) { if (ModelState.IsValid) { db.Exams.Add(exam); db.SaveChanges(); } return(RedirectToAction("Index")); }
public IActionResult Delete(int id) { Exam exam = _examContext.Exams.FirstOrDefault(x => x.ID == id); exam.IsDeleted = true; _examContext.SaveChanges(); return(Json("Sınav Başarılı Bir Şekilde Silindi!")); }
private void btnSave_Click(object sender, EventArgs e) { if (question.QueBody != null && txtQuestion.Text.Trim() != "" && choices.Count > 0) { ExamContext ctx; try { if (numeric.Value > 1 && numeric.Value < 100) { question.Grade = 1; } else { question.Grade = (int)numeric.Value; } question.QueBody = txtQuestion.Text; using (ctx = new ExamContext()) { ctx.Questions.Add(question); ctx.Choices.AddRange(choices); ctx.SaveChanges(); ctx.ChoQues.AddRange(choices.Select(s => new ChoQue() { ChoId = s.ChoId, QueId = question.QueId })); ctx.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("can't add question", "failed to add questions"); } } else { MessageBox.Show("can't add question", "failed to add questions"); } }
public ActionResult Create([Bind(Include = "EventName,EventDate,EventPlace,EventDetails")] Event @event) { try { if (ModelState.IsValid) { db.Events.Add(@event); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(@event)); }
public ActionResult Create([Bind(Include = "id,section_number,program_id,course_id,student_enrolled,faculty_id,is_deleted,created_by,created_on,modified_by,modified_on,class_weekday,class_start_time,room_id")] section section) { string err = ""; var tempList = db.sections.Where(s => s.course_id == section.course_id); foreach (var item in tempList) { if (item.section_number == section.section_number) { err = "Cannot create duplicated section number for same course. This section number exists for this course."; section.section_number = null; break; } } if (section.section_number != null) { if (ModelState.IsValid) { section.created_on = DateTime.Now; section.student_enrolled = 30; db.sections.Add(section); db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.course_id = new SelectList(db.courses.Where(p => p.is_deleted == false).OrderBy(o => o.code), "id", "courseDropdown", section.course_id); ViewBag.faculty_id = new SelectList(db.faculties.Where(c => c.is_deleted == false).OrderBy(o => o.first_name), "id", "fullName", section.faculty_id); ViewBag.program_id = new SelectList(db.programs.Where(c => c.is_deleted == false), "id", "title", section.program_id); ViewBag.room_id = new SelectList(db.rooms.Where(c => c.is_deleted == false).OrderBy(o => o.name), "id", "name", section.room_id); ViewBag.Error = err; var weekDays = Enum.GetValues(typeof(DayOfWeek)).Cast <DayOfWeek>() .Select(dow => new { Value = (int)dow - 1, Text = dow.ToString() }) .ToList(); ViewBag.class_weekday = new SelectList(weekDays, "Value", "Text", section.class_weekday); return(View(section)); }
public IActionResult OnGet(Guid guid) { var student = _db.Students.FirstOrDefault(s => s.Guid == guid); if (student is null) { return(RedirectToPage("/Students/Index")); } _db.Students.Remove(student); _db.SaveChanges(); return(RedirectToPage("/Students/Index")); }
public IActionResult CreateUser(User user) { if (ModelState.IsValid) { if (dbContext.Users.Any(u => u.Email == user.Email)) { ModelState.AddModelError("Email", "Email already taken"); return(View("Index")); } PasswordHasher <User> Hasher = new PasswordHasher <User>(); user.Password = Hasher.HashPassword(user, user.Password); dbContext.Add(user); dbContext.SaveChanges(); HttpContext.Session.SetInt32("userID", user.UserID); return(RedirectToAction("Dashboard")); } else { return(View("Index")); } }
public ActionResult Create([Bind(Include = "VacationFor,StartDate,EndDate,ClassResumesOn")] Holiday holiday) { try { if (ModelState.IsValid) { db.Holidays.Add(holiday); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(holiday)); }
public HomeController(ExamContext context) { this._context = context; if (!_context.Exams.Any()) { _context.Add(new Exam() { Counter = 1 }); _context.SaveChanges(); } }