<file_sep>﻿

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using STAWebsite2.Models;

namespace STAWebsite2.DAL
{
    public class STAInitializer : System.Data.Entity.DropCreateDatabaseIfModelChanges<STAContext>
    {
        protected override void Seed(STAContext context)
        {
            var students = new List<Student>
            {
            new Student{Name="<NAME>",StudentID=160104001,Semester=2,Year=3,WarningNo=0,LoginStatus="yes",Password="<PASSWORD>"},
            new Student{Name="<NAME>",StudentID=160104008,Semester=2,Year=3,WarningNo=0,LoginStatus="yes",Password="<PASSWORD>"},
            new Student{Name="<NAME>",StudentID=160104012,Semester=2,Year=3,WarningNo=0,LoginStatus="yes",Password="<PASSWORD>"}
            };

            students.ForEach(s => context.Students.Add(s));
            context.SaveChanges();
            var courses = new List<Course>
            {
            new Course{CourseID=3211,Title="Data Communication",avgSCRating=0,verificationCode="hf4ry7"},
            new Course{CourseID=3213,Title="Operating System",avgSCRating=0,verificationCode="vfd34x"},
            new Course{CourseID=3214,Title="Operating System Lab",avgSCRating=0,verificationCode="45lshf"},
            new Course{CourseID=3215,Title="Microcontroller based System Design",avgSCRating=0,verificationCode="hdf12d"},
            new Course{CourseID=3216,Title="Microcontroller based System Design Lab",avgSCRating=0,verificationCode="as5bhg"},
            new Course{CourseID=3223,Title="Information System Design & Software Engineering",avgSCRating=0,verificationCode="7tet89"},
            new Course{CourseID=3224,Title="Information System Design & Software Engineering Lab",avgSCRating=0,verificationCode="gh457r"},
            new Course{CourseID=3200,Title="Software Development V",avgSCRating=0,verificationCode="h8t5uh"},
            new Course{CourseID=3207,Title="Industrial Law & Safety Management",avgSCRating=0,verificationCode="s030ii"}
            };
            courses.ForEach(s => context.Courses.Add(s));
            context.SaveChanges();

            var instructors = new List<Instructor>
            {
                new Instructor{InstructorID=0001,Name="<NAME>",avgIRating=0,Department="CSE",LoginStatus="no",Password="<PASSWORD>",WarningNo=0},
                new Instructor{InstructorID=0002,Name="<NAME>",avgIRating=0,Department="CSE",LoginStatus="no",Password="<PASSWORD>",WarningNo=0},
                new Instructor{InstructorID=0003,Name="<NAME>",avgIRating=0,Department="CSE",LoginStatus="no",Password="<PASSWORD>",WarningNo=0}
            };
            instructors.ForEach(s => context.Instructors.Add(s));
            context.SaveChanges();

            var iratings = new List<IRating>
            {
                new IRating{SubCriteria1=5,SubCriteria2=5,SubCriteria3=5,SubCriteria4=5,SubCriteria5=5,SubCriteria6=5,
                    SubCriteria7 =5,SubCriteria8=5,SubCriteria9=5,SubCriteria10=5,SubCriteria11=5,SubCriteria12=5,
                    SubCriteria13 =5,SubCriteria14=5,SubCriteria15=5,SubCriteria16=5,SubCriteria17=5,SubCriteria18=5,
                    SubCriteria19 =5,SubCriteria20=5,Review="Today's class was very englightening.",StudentID=160104001,InstructorID=0001}
            };
            iratings.ForEach(s => context.IRatings.Add(s));
            context.SaveChanges();

            var scratings = new List<SCRating>
            {
                new SCRating{InstructorID=0001,CourseID=3213,SubCriteria1=5,SubCriteria2=5,SubCriteria3=5,SubCriteria4=5,SubCriteria5=5,SubCriteria6=5,SubCriteria7=5}
            };
            scratings.ForEach(s => context.SCRatings.Add(s));
            context.SaveChanges();

            var studentcourses = new List<Student_Course>
            {
                new Student_Course{CourseID=3213,StudentID=160104001},
                new Student_Course{CourseID=3214,StudentID=160104001},
                new Student_Course{CourseID=3213,StudentID=160104008}
            };
            studentcourses.ForEach(s => context.Student_Courses.Add(s));
            context.SaveChanges();
        }
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;

namespace STAWebsite2.Models
{
    public class Course
    {
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int CourseID { get; set; }
        public string Title { get; set; }
        public float avgSCRating { get; set; }
        public string verificationCode { get; set; }

        public int? InstructorID { get; set; }
        public virtual Instructor Instructor { get; set; }
        public virtual ICollection<Student_Course> Student_Courses { get; set; }
        public virtual ICollection<SCRating> SCRatings { get; set; }
    }
}<file_sep># CSE3200-Software-Development-V<file_sep>﻿using STAWebsite2.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Web;

namespace STAWebsite2.DAL
{
    public class STAContext :DbContext
    {
        public STAContext() : base("STAContext")
        {
        }

        public DbSet<Student> Students { get; set; }
        public DbSet<Instructor> Instructors { get; set; }
        public DbSet<Course> Courses { get; set; }
        public DbSet<SCRating> SCRatings { get; set; }
        public DbSet<IRating> IRatings { get; set; }
        public DbSet<Student_Course> Student_Courses { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace STAWebsite2.Models
{
    public class Student_Course
    {
        public int Student_CourseID { get; set; }
        public int? CourseID { get; set; }
        public int? StudentID { get; set; }

        public virtual Student Student { get; set; }
        public virtual Course Course { get; set; }
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace STAWebsite2.Models
{
    public class IRating
    {
        public int IRatingID { get; set; }
        public int SubCriteria1 { get; set; }
        public int SubCriteria2 { get; set; }
        public int SubCriteria3 { get; set; }
        public int SubCriteria4 { get; set; }
        public int SubCriteria5 { get; set; }
        public int SubCriteria6 { get; set; }
        public int SubCriteria7 { get; set; }
        public int SubCriteria8 { get; set; }
        public int SubCriteria9 { get; set; }
        public int SubCriteria10 { get; set; }
        public int SubCriteria11 { get; set; }
        public int SubCriteria12 { get; set; }
        public int SubCriteria13 { get; set; }
        public int SubCriteria14 { get; set; }
        public int SubCriteria15 { get; set; }
        public int SubCriteria16 { get; set; }
        public int SubCriteria17 { get; set; }
        public int SubCriteria18 { get; set; }
        public int SubCriteria19 { get; set; }
        public int SubCriteria20 { get; set; }
        public string Review { get; set; }

        public virtual Student Student { get; set; }
        public virtual Instructor Instructor { get; set; }
        public int? StudentID { get; set; }
        public int? InstructorID { get; set; }
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using STAWebsite2.DAL;
using STAWebsite2.Models;

namespace STAWebsite2.Controllers
{
    public class IRatingController : Controller
    {
        private STAContext db = new STAContext();

        // GET: IRating
        public ActionResult Index()
        {
            var iRatings = db.IRatings.Include(i => i.Instructor).Include(i => i.Student);
            return View(iRatings.ToList());
        }

        // GET: IRating/Details/5
        public ActionResult Details(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            IRating iRating = db.IRatings.Find(id);
            if (iRating == null)
            {
                return HttpNotFound();
            }
            return View(iRating);
        }

        // GET: IRating/Create
        public ActionResult Create()
        {
            ViewBag.InstructorID = new SelectList(db.Instructors, "InstructorID", "Name");
            ViewBag.StudentID = new SelectList(db.Students, "StudentID", "Name");
            return View();
        }

        // POST: IRating/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "IRatingID,SubCriteria1,SubCriteria2,SubCriteria3,SubCriteria4,SubCriteria5,SubCriteria6,SubCriteria7,SubCriteria8,SubCriteria9,SubCriteria10,SubCriteria11,SubCriteria12,SubCriteria13,SubCriteria14,SubCriteria15,SubCriteria16,SubCriteria17,SubCriteria18,SubCriteria19,SubCriteria20,Review,StudentID,InstructorID")] IRating iRating)
        {
            if (ModelState.IsValid)
            {
                db.IRatings.Add(iRating);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.InstructorID = new SelectList(db.Instructors, "InstructorID", "Name", iRating.InstructorID);
            ViewBag.StudentID = new SelectList(db.Students, "StudentID", "Name", iRating.StudentID);
            return View(iRating);
        }

        // GET: IRating/Edit/5
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            IRating iRating = db.IRatings.Find(id);
            if (iRating == null)
            {
                return HttpNotFound();
            }
            ViewBag.InstructorID = new SelectList(db.Instructors, "InstructorID", "Name", iRating.InstructorID);
            ViewBag.StudentID = new SelectList(db.Students, "StudentID", "Name", iRating.StudentID);
            return View(iRating);
        }

        // POST: IRating/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include = "IRatingID,SubCriteria1,SubCriteria2,SubCriteria3,SubCriteria4,SubCriteria5,SubCriteria6,SubCriteria7,SubCriteria8,SubCriteria9,SubCriteria10,SubCriteria11,SubCriteria12,SubCriteria13,SubCriteria14,SubCriteria15,SubCriteria16,SubCriteria17,SubCriteria18,SubCriteria19,SubCriteria20,Review,StudentID,InstructorID")] IRating iRating)
        {
            if (ModelState.IsValid)
            {
                db.Entry(iRating).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.InstructorID = new SelectList(db.Instructors, "InstructorID", "Name", iRating.InstructorID);
            ViewBag.StudentID = new SelectList(db.Students, "StudentID", "Name", iRating.StudentID);
            return View(iRating);
        }

        // GET: IRating/Delete/5
        public ActionResult Delete(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            IRating iRating = db.IRatings.Find(id);
            if (iRating == null)
            {
                return HttpNotFound();
            }
            return View(iRating);
        }

        // POST: IRating/Delete/5
        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            IRating iRating = db.IRatings.Find(id);
            db.IRatings.Remove(iRating);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace STAWebsite2.Models
{
    public class SCRating
    {
        public int SCRatingID { get; set; }
        public int SubCriteria1 { get; set; }
        public int SubCriteria2 { get; set; }
        public int SubCriteria3 { get; set; }
        public int SubCriteria4 { get; set; }
        public int SubCriteria5 { get; set; }
        public int SubCriteria6 { get; set; }
        public int SubCriteria7 { get; set; }
        public string Review { get; set; }

        public virtual Instructor Instructor { get; set; }
        public virtual Course Course { get; set; }
        public int? CourseID { get; set; }
        public int? InstructorID { get; set; }
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;

namespace STAWebsite2.Models
{
    public class Instructor
    {
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int InstructorID { get; set; }

        [Required(ErrorMessage = "*Enter valid name")]
        [Display(Name = "Instructor Name")]
        public string Name { get; set; }
        public string Department { get; set; }
        [Required(ErrorMessage = "*Enter valid password")]
        [DataType(DataType.Password)]
        [Display(Name = "Password")]
        public string Password { get; set; }
        public float avgIRating { get; set; }
        public int WarningNo { get; set; }
        public string LoginStatus { get; set; }

        public virtual ICollection<Course> Courses { get; set; }
        public virtual ICollection<IRating> IRatings { get; set; }
        public virtual ICollection<SCRating> SCRatings { get; set; }
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using STAWebsite2.DAL;
using STAWebsite2.Models;

namespace STAWebsite2.Controllers
{
    public class SCRatingController : Controller
    {
        private STAContext db = new STAContext();

        // GET: SCRating
        public ActionResult Index()
        {
            var sCRatings = db.SCRatings.Include(s => s.Course).Include(s => s.Instructor);
            return View(sCRatings.ToList());
        }

        // GET: SCRating/Details/5
        public ActionResult Details(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            SCRating sCRating = db.SCRatings.Find(id);
            if (sCRating == null)
            {
                return HttpNotFound();
            }
            return View(sCRating);
        }

        // GET: SCRating/Create
        public ActionResult Create()
        {
            ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Title");
            ViewBag.InstructorID = new SelectList(db.Instructors, "InstructorID", "Name");
            return View();
        }

        // POST: SCRating/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "SCRatingID,SubCriteria1,SubCriteria2,SubCriteria3,SubCriteria4,SubCriteria5,SubCriteria6,SubCriteria7,Review,CourseID,InstructorID")] SCRating sCRating)
        {
            if (ModelState.IsValid)
            {
                db.SCRatings.Add(sCRating);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Title", sCRating.CourseID);
            ViewBag.InstructorID = new SelectList(db.Instructors, "InstructorID", "Name", sCRating.InstructorID);
            return View(sCRating);
        }

        // GET: SCRating/Edit/5
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            SCRating sCRating = db.SCRatings.Find(id);
            if (sCRating == null)
            {
                return HttpNotFound();
            }
            ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Title", sCRating.CourseID);
            ViewBag.InstructorID = new SelectList(db.Instructors, "InstructorID", "Name", sCRating.InstructorID);
            return View(sCRating);
        }

        // POST: SCRating/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include = "SCRatingID,SubCriteria1,SubCriteria2,SubCriteria3,SubCriteria4,SubCriteria5,SubCriteria6,SubCriteria7,Review,CourseID,InstructorID")] SCRating sCRating)
        {
            if (ModelState.IsValid)
            {
                db.Entry(sCRating).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Title", sCRating.CourseID);
            ViewBag.InstructorID = new SelectList(db.Instructors, "InstructorID", "Name", sCRating.InstructorID);
            return View(sCRating);
        }

        // GET: SCRating/Delete/5
        public ActionResult Delete(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            SCRating sCRating = db.SCRatings.Find(id);
            if (sCRating == null)
            {
                return HttpNotFound();
            }
            return View(sCRating);
        }

        // POST: SCRating/Delete/5
        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            SCRating sCRating = db.SCRatings.Find(id);
            db.SCRatings.Remove(sCRating);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace STAWebsite2.Models
{
    public class Student
    {
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int StudentID { get; set; }

        [Required(ErrorMessage = "*Enter valid name")]
        [Display(Name = "Student Name")]

        public string Name { get; set; }
        public int Year { get; set; }
        public int Semester { get; set; }

        [Required(ErrorMessage = "*Enter valid password")]
        [DataType(DataType.Password)]
        [Display(Name = "Password")]

        public string Password { get; set; }
        public int WarningNo { get; set; }
        public string LoginStatus { get; set; }

        public virtual ICollection<Student_Course> Student_Courses { get; set; }
        public virtual ICollection<IRating> IRatings { get; set; }
    }
    
}