Beispiel #1
0
        // _context.Users.Include(p => p.Photos).FirstOrDefaultAsync(i => i.Id == id);

        //public List<Course> CourseStatists()
        //{
        //    var cs = (from c in _universityDB.Courses
        //              join s in _universityDB.Semesters on c.SemesterId equals s.Id.ToString()
        //              join t in _universityDB.Teachers on c.TeacherId equals t.Id
        //              select new{
        //                  c.Id,
        //                  c.Name,
        //                  c.Code,
        //                  s.SemesterName

        //                }).ToList();
        //    return cs;
        //}


        public bool AddCourse(Course course)
        {
            var t = _universityDB.Courses.Add(course);
            var y = _universityDB.SaveChanges();

            return(y > 0);
        }
        public ActionResult Create(Student aStudent, Course aCourse, DateTime date)
        {
            Create();
            if (aStudent.StudentId == 0 || aCourse.CourseId == 0)
            {
                ViewBag.ErrorMessage = "All fields are required.";
                return(View());
            }
            Enrollment enrollment = new Enrollment();

            enrollment.StudentId = aStudent.StudentId;
            enrollment.CourseId  = aCourse.CourseId;
            enrollment.Date      = date;
            Student student = (db.Students.Where(s => s.StudentId == aStudent.StudentId)).Single();
            Course  course  = db.Courses.Single(c => c.CourseId == aCourse.CourseId);
            bool    check   = db.Enrollments.Count(c => c.StudentId == aStudent.StudentId && c.CourseId == aCourse.CourseId) == 0;

            if (check)
            {
                db.Enrollments.Add(enrollment);
                db.SaveChanges();
                ViewBag.Message = course.Code + " has assigned for " + student.RegNo;
                return(View(enrollment));
            }

            enrollment.Student   = student;
            enrollment.Course    = course;
            ViewBag.ErrorMessage = student.RegNo + " has already enrolled for " + course.Code;
            return(View(enrollment));
        }
        public ActionResult Create([Bind(Include = "Id,DeptCode,DeptName")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Deparments.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(department));
        }
        public ActionResult Create(Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();
                ViewBag.Message = department.Code + " has been saved into database.";
                return(View());
            }

            return(View(department));
        }
Beispiel #5
0
        public ActionResult Create(Semester semester)
        {
            string              data     = JsonConvert.SerializeObject(semester);
            StringContent       content  = new StringContent(data, Encoding.UTF8, "application/json");
            HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/user", content).Result;

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            db.SaveChanges();
            return(View());
        }
Beispiel #6
0
        public ActionResult Create(Course course)
        {
            PopulateDropdownList(course);
            if (ModelState.IsValid)
            {
                db.Courses.Add(course);
                db.SaveChanges();
                ViewBag.Message = "This course " + course.Name + " has been saved.";
                return(View(course));
            }

            return(View(course));
        }
        public ActionResult Save([Bind(Include = "Id,CourseCode,CourseName,CourseCredit,CourseDescription,CourseAssignTo,CourseStatus,DepartmentId,SemesterId")] Course course)
        {
            if (ModelState.IsValid)
            {
                db.Courses.Add(course);
                db.SaveChanges();
                ViewBag.Message = "Course saved successfully";
                // return RedirectToAction("Index");
            }

            ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DeptCode", course.DepartmentId);
            ViewBag.SemesterId   = new SelectList(db.Semesters, "Id", "SemesterName", course.SemesterId);
            return(View(course));
        }
Beispiel #8
0
        public ActionResult Create(Course course)
        {
            string              data     = JsonConvert.SerializeObject(course);
            StringContent       content  = new StringContent(data, Encoding.UTF8, "application/json");
            HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/user", content).Result;

            //if (response.IsSuccessStatusCode)
            //{
            //    return RedirectToAction("Index");
            //}
            db.Courses.Add(course);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Create(Teacher teacher)
 {
     ViewBag.DesignationId = new SelectList(db.Designations, "DesignationId", "Name", teacher.DesignationId);
     ViewBag.DepartmentId  = new SelectList(db.Departments, "DepartmentId", "Code", teacher.DepartmentId);
     if (ModelState.IsValid)
     {
         teacher.RemainingCredit = teacher.CreditToBeTaken;
         db.Teachers.Add(teacher);
         db.SaveChanges();
         ViewBag.Message = teacher.Name + " has been saved in database.";
         return(View());
     }
     return(View());
 }
        public ActionResult Create(Predmet predmet)
        {
            try
            {
                db.Predmets.Add(predmet);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #11
0
        public ActionResult Save(/*[Bind(Include="Id,Name,Email,ContactNo,Date,Address,DepartmentId,StudentRegNo")]*/ Student student)
        {
            if (ModelState.IsValid)
            {
                student.StudentRegNo = GetStudentRegNo(student);
                db.Students.Add(student);
                db.SaveChanges();
                ViewBag.Message = "Student Registered Successfully";
                //return RedirectToAction("Index");
            }

            ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DeptCode", student.DepartmentId);
            return(View(student));
        }
Beispiel #12
0
        public ActionResult Save([Bind(Include = "Id,TeacherName,TeacherAddress,TeacherEmail,TeacherContactNo,DesignationId,DepartmentId,CreditTaken,CreditLeft")] Teacher teacher)
        {
            if (ModelState.IsValid)
            {
                db.Teachers.Add(teacher);
                db.SaveChanges();
                ViewBag.Message = "Teacher Saved Successfully";
                // return RedirectToAction("Index");
            }

            ViewBag.DepartmentId  = new SelectList(db.Departments, "Id", "DeptCode", teacher.DepartmentId);
            ViewBag.DesignationId = new SelectList(db.Designations, "Id", "DesignationName", teacher.DesignationId);
            return(View(teacher));
        }
        public ActionResult Create([Bind(Include = "Id,StudentRegNo,Name,Email,Contact,RegDate,Address,DepartmentId")] Student student)
        {
            string              data     = JsonConvert.SerializeObject(student);
            StringContent       content  = new StringContent(data, Encoding.UTF8, "application/json");
            HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/user", content).Result;

            //if (response.IsSuccessStatusCode)
            //{
            //    return RedirectToAction("Index");
            //}
            db.Students.Add(student);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Beispiel #14
0
        public async Task <ActionResult> Register(Users model)
        {
            if (ModelState.IsValid)
            {
                UniversityDBContext _db = new UniversityDBContext();
                var user = _db.users.Any(p => p.UserName == model.UserName);
                if (!user)
                {
                    _db.users.Add(model);
                    _db.SaveChanges();
                }
                else
                {
                    ModelState.AddModelError("", "UserName already exists.");
                    return(View(model));
                }
                //var user = new ApplicationUser() { UserName = model.UserName };
                //var result = await UserManager.CreateAsync(user, model.Password);
                //if (result.Succeeded)
                //{
                //    await SignInAsync(user, isPersistent: false);
                //    return RedirectToAction("Index", "Home");
                //}
                //else
                //{
                //    AddErrors(result);
                //}
            }

            // If we got this far, something failed, redisplay form
            return(View("Login"));
        }
Beispiel #15
0
        public ActionResult Save([Bind(Include = "Id,DepartmentId,TeacherId,CreditTaken,CreditLeft,CourseId,Name,Credit")] CourseAssign courseassign)
        {
            if (ModelState.IsValid)
            {
                db.CourseAssigns.Add(courseassign);
                db.SaveChanges();
                ViewBag.Message = "Course Assigned Successful";

                //  return RedirectToAction("Index");
            }

            ViewBag.CourseID     = new SelectList(db.Courses, "Id", "CourseCode", courseassign.CourseId);
            ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DeptCode", courseassign.DepartmentId);
            ViewBag.TeacherId    = new SelectList(db.Teachers, "Id", "TeacherName", courseassign.TeacherId);
            return(View(courseassign));
        }
        public ActionResult Create(Student student)
        {
            ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Code", student.DepartmentId);
            if (ModelState.IsValid)
            {
                int count = db.Students.Count(s => s.DepartmentId == student.DepartmentId & s.Date.Year == student.Date.Year);
                //student.RegNo = "OOP0140" + (count+1);
                Department department = db.Departments.Find(student.DepartmentId);
                student.RegNo = department.Code + student.Date.Year + (count + 1).ToString("D3");
                db.Students.Add(student);
                db.SaveChanges();
                ViewBag.Message = student.Name + "'s registration number is " + student.RegNo;
                return(View());
            }

            return(View(student));
        }
        public JsonResult EnrollStudentToCourse(EnrollCourse enrollCourse)
        {
            var enrollCourses = db.EnrollCourses.Where(m => m.RegistrationNo == enrollCourse.RegistrationNo && m.CourseId == enrollCourse.CourseId).ToList();

            if (enrollCourses.Count() == 1)
            {
                var id   = enrollCourses[0].Id;
                var date = enrollCourses[0].EnrollDate;
                enrollCourse.Id         = id;
                enrollCourse.EnrollDate = date;
                db.EnrollCourses.AddOrUpdate(enrollCourse);
            }
            else
            {
                db.EnrollCourses.Add(enrollCourse);
            }

            db.SaveChanges();
            return(Json(true));
        }
        public ActionResult Create(IspitResponse ispit)
        {
            try
            {
                Ispit newIspit = new Ispit();
                initializeIspit(newIspit, ispit);

                db.Ispits.Add(newIspit);
                db.SaveChanges();

                //List<Ispit> ispiti = initializeIspitList();

                //initializeCreateViewData(newIspit);

                return(RedirectToAction("UpdatedList", new { id = newIspit.ispitId }));
            }
            catch
            {
                return(RedirectToAction("Create"));
            }
        }
Beispiel #19
0
        public void AddStudent(StudentDTO studentDTO)
        {
            Student student = new Student()
            {
                Email    = studentDTO.Email,
                Name     = studentDTO.Name,
                Surname  = studentDTO.Surname,
                Password = studentDTO.Password
            };

            _context.Students.Add(student);
            _context.SaveChanges();
        }
        public ActionResult Create([Bind(Include = "Id,DepartmentId,CourseId,RoomId,DayId,StartTime,EndTime,RoomStatus")] ClassRoomAllocation classroomallocation)
        {
            if (ModelState.IsValid)
            {
                db.ClassRoomAllocations.Add(classroomallocation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CourseId     = new SelectList(db.Courses, "Id", "CourseCode", classroomallocation.CourseId);
            ViewBag.DayId        = new SelectList(db.Days, "Id", "Name", classroomallocation.DayId);
            ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DeptCode", classroomallocation.DepartmentId);
            ViewBag.RoomId       = new SelectList(db.Rooms, "Id", "Name", classroomallocation.RoomId);
            return(View(classroomallocation));
        }
        public ActionResult Create(ClassRoomAllocation classRoomAllocation)
        {
            Create();
            if (classRoomAllocation.DepartmentId == 0 || classRoomAllocation.CourseId == 0 || classRoomAllocation.ClassRoomId == 0 || classRoomAllocation.DayId == 0)
            {
                return(View());
            }
            string timeFrom = classRoomAllocation.TimeFrom;
            string timeTo   = classRoomAllocation.TimeTo;

            Course     aCourse     = (db.Courses.Where(course => course.CourseId == classRoomAllocation.CourseId)).Single();
            Department aDepartment = (db.Departments.Where(d => d.DepartmentId == aCourse.DepartmentId)).Single();
            Day        day         = db.Days.Single(d => d.DayId == classRoomAllocation.DayId);
            ClassRoom  classRoom   = db.ClassRooms.Single(c => c.ClassRoomId == classRoomAllocation.ClassRoomId);
            List <ClassRoomAllocation> allocationRooms = (db.ClassRoomAllocations.Where(c =>
                                                                                        (c.DayId == classRoomAllocation.DayId &&
                                                                                         c.ClassRoomId == classRoomAllocation.ClassRoomId))).ToList();

            List <ClassRoomAllocation> allocationCourses =
                db.ClassRoomAllocations.Where(
                    c => (c.DayId == classRoomAllocation.DayId && c.CourseId == classRoomAllocation.CourseId)).ToList();
            string  timeFrom2 = "";
            string  timeTo2   = "";
            int     id        = 0;
            Boolean confirm   = false;

            if (timeFrom == timeTo)
            {
                confirm = true;
            }

            foreach (ClassRoomAllocation room in allocationRooms)
            {
                bool check = CheckOverlapping(timeFrom, timeTo, room.TimeFrom, room.TimeTo);
                if (check)
                {
                    confirm   = true;
                    timeFrom2 = room.TimeFrom;
                    timeTo2   = room.TimeTo;
                    id        = room.CourseId;
                }
            }

            foreach (ClassRoomAllocation room in allocationCourses)
            {
                bool check = CheckOverlapping(timeFrom, timeTo, room.TimeFrom, room.TimeTo);
                if (check)
                {
                    confirm = true;
                }
            }

            if (!confirm)
            {
                LoadDropDownList(classRoomAllocation);
                classRoomAllocation.Department = aDepartment;
                if (ModelState.IsValid)
                {
                    db.ClassRoomAllocations.Add(classRoomAllocation);
                    db.SaveChanges();
                    if (aCourse.Teacher == null)
                    {
                        ViewBag.Success = aCourse.Code + " has been allocated in " + classRoom.RoomNo +
                                          " class room. And the schedual is " + day.Name + " at " +
                                          classRoomAllocation.TimeFrom + "-" + classRoomAllocation.TimeTo +
                                          " and teacher is not assigned yet.";
                    }
                    else
                    {
                        ViewBag.Success = aCourse.Code + " has been allocated in " + classRoom.RoomNo +
                                          " class room. And the schedual is " + day.Name + " at " +
                                          classRoomAllocation.TimeFrom + "-" + classRoomAllocation.TimeTo +
                                          " and the teacher of this course is" + aCourse.Teacher.Name;
                    }
                    return(View());
                }
            }
            Course course2 = db.Courses.Single(c => c.CourseId == id);

            LoadDropDownList(classRoomAllocation);
            if (course2.Teacher == null)
            {
                ViewBag.ErrorMessage = "This Room: " + classRoom.RoomNo + " has already allocated at " + timeFrom2 + "-" + timeTo2 + " for " + course2.Code +
                                       " and teacher is not assigned yet.";
            }
            else
            {
                ViewBag.ErrorMessage = "This Room: " + classRoom.RoomNo + " has already allocated at " + timeFrom2 + "-" + timeTo2 + " for " + course2.Code +
                                       " and the teacher of this course is " + course2.Teacher.Name;
            }

            return(View(classRoomAllocation));
        }
 public void Add(Course course)
 {
     _ctx.Courses.Add(course);
     _ctx.SaveChanges();
 }
 public void Add(Course course)
 {
     _context.Courses.Add(course);
     _context.SaveChanges();
 }
Beispiel #24
0
 public void Save()
 {
     _context.SaveChanges();
 }
Beispiel #25
0
 public void Save()
 {
     universityDBContext.SaveChanges();
 }
Beispiel #26
0
 public void Save()
 {
     db.SaveChanges();
 }
 void IRepository <Student> .Save()
 {
     db.SaveChanges();
 }
 public void Save()
 {
     _ctx.SaveChanges();
 }
 void IRepository <Groupe> .Save()
 {
     db.SaveChanges();
 }
Beispiel #30
0
 void IRepository <Specialty> .Save()
 {
     db.SaveChanges();
 }