public ActionResult ShowUserTickets() { int userId = LoginFilter.GetUserId(); TicketRepository repository = new TicketRepository(); List <Ticket> tickets = repository.GetAll(); List <Ticket> userTickets = new List <Ticket>(); foreach (var tick in tickets) { if (tick.UserId == userId) { userTickets.Add(tick); } else { ViewBag.Message = "This user has no tickets yet!"; // return RedirectToAction("Index", "Home"); } } TicketsListViewModel model = new TicketsListViewModel(); model.Tickets = userTickets; return(View(model)); }
public ActionResult ShowTeacherSubjects() { int userId = LoginFilter.GetUserId(); SubjectRepository repository = new SubjectRepository(); List <Subject> subjects = repository.GetAll(); List <Subject> teacherSubjects = new List <Subject>(); foreach (var subject in subjects) { if (subject.TeacherId == userId) { teacherSubjects.Add(subject); } else { ViewBag.Message = "This user has no subjects yet!"; } } SubjectListViewModel model = new SubjectListViewModel(); model.Subjects = teacherSubjects; return(View(model)); }
public ActionResult Create(int id) { int userId = LoginFilter.GetUserId(); Ticket ticket = new Ticket(); ticket.EventId = id; ticket.UserId = userId; var repository = new TicketRepository(); repository.Insert(ticket); return(RedirectToAction("Index")); }
public ActionResult ShowProfile() { int id = LoginFilter.GetUserId(); UserRepository repository = new UserRepository(); UserEditViewModel model = new UserEditViewModel(); User user = repository.GetById(id); model.Id = LoginFilter.GetUserId(); model.ImgURL = user.ImgURL; model.Username = user.Username; model.Password = user.Password; model.Email = user.Email; model.FirstName = user.FirstName; model.LastName = user.LastName; user.IsAdmin = model.IsAdmin; return(View(model)); }
public ActionResult Delete(UserDeleteViewModel model) { int id = LoginFilter.GetUserId(); UserRepository repository = new UserRepository(); if (model.Id.ToString() != String.Empty) { repository.Delete(model.Id); } if (model.Id == id) { return(RedirectToAction("Logout", "Home")); } else { return(RedirectToAction("Index")); } }
public ActionResult ShowProfile() { int id = LoginFilter.GetUserId(); TeacherRepository repository = new TeacherRepository(); CRUDTeacherViewModel model = new CRUDTeacherViewModel(); Teacher teacher = repository.GetById(id); model.Id = LoginFilter.GetUserId(); model.ImgURL = teacher.ImgURL; model.Username = teacher.Username; model.Password = teacher.Password; model.Email = teacher.Email; model.FirstName = teacher.FirstName; model.LastName = teacher.LastName; teacher.IsAdmin = model.IsAdmin; model.Subject = teacher.Subject; model.IsTeacher = teacher.IsTeacher; return(View(model)); }
public ActionResult ShowProfile() { int id = LoginFilter.GetUserId(); StudentRepository repository = new StudentRepository(); CRUDStudentViewModel model = new CRUDStudentViewModel(); Student student = repository.GetById(id); model.Id = LoginFilter.GetUserId(); model.ImgURL = student.ImgURL; model.Username = student.Username; model.Password = student.Password; model.Email = student.Email; model.FirstName = student.FirstName; model.LastName = student.LastName; student.IsAdmin = model.IsAdmin; model.FacultyNumber = student.FacultyNumber; model.Specialty = student.Specialty; model.GroupId = student.GroupId; model.IsTeacher = student.IsTeacher; model.IsStudent = student.IsStudent; return(View(model)); }