public IHttpActionResult PutTeacher(int id, Teacher teacher)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != teacher.ID)
            {
                return(BadRequest());
            }

            db.Entry(teacher).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeacherExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutSubject(int id, Subject subject)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != subject.ID)
            {
                return BadRequest();
            }

            db.Entry(subject).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SubjectExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 3
0
        public ActionResult OpenExam(int id)
        {
            IEnumerable <Result> results = db.Results.Where(m => m.S_id == id).ToList();

            foreach (var item in results)
            {
                item.StartExam = true;
                item.result1   = 0.0;
                item.S_GPA     = 0;
                item.grade     = "0";


                db.Entry(item).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(View(results));
        }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "Dep_id,name")] Department department)
 {
     if (ModelState.IsValid)
     {
         db.Entry(department).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(department));
 }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "id,title")] Models.Rule rule)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rule).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(rule));
 }
Ejemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "L_id,name")] Level level)
 {
     if (ModelState.IsValid)
     {
         db.Entry(level).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(level));
 }
Ejemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "P_id,name,emai,password,mobile,N_N,rule,approval,P_image")] Professor professor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(professor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(professor));
 }
Ejemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "E_id,E_name,S_id,duration")] ExamQuestion examQuestion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(examQuestion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.S_id = new SelectList(db.Subjects, "S_id", "name", examQuestion.S_id);
     return(View(examQuestion));
 }
Ejemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "A_id,name,mobile,N_N,A_image,email,password")] Admin admin)
 {
     if (ModelState.IsValid)
     {
         admin.rule            = "Admin";
         db.Entry(admin).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("AdminPage"));
     }
     return(View(admin));
 }
Ejemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "MQ_id,content,option1,optoin2,option3,option4,correct,def_level,CH_id")] MCQquestion mCQquestion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mCQquestion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ProfessorSubjects", "Subjects"));
     }
     ViewBag.CH_id = new SelectList(db.Chapters, "CH_id", "name", mCQquestion.CH_id);
     return(View(mCQquestion));
 }
Ejemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "CH_id,name,S_id")] Chapter chapter)
 {
     if (ModelState.IsValid)
     {
         db.Entry(chapter).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ProfessorSubjects", "Subjects"));
     }
     ViewBag.S_id = new SelectList(db.Subjects, "S_id", "name", chapter.S_id);
     return(View(chapter));
 }
Ejemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "E_S_id,Type_Q,S_id,def_level,NumofQ,E_id,CH_id,post")] E_Structures e_Structures)
 {
     if (ModelState.IsValid)
     {
         db.Entry(e_Structures).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ShowExam", "E_Structures", new { @id = e_Structures.E_id }));
     }
     ViewBag.CH_id = new SelectList(db.Chapters, "CH_id", "name", e_Structures.CH_id);
     ViewBag.E_id  = new SelectList(db.ExamQuestions, "E_id", "E_name", e_Structures.E_id);
     return(View(e_Structures));
 }
Ejemplo n.º 13
0
 public ActionResult Edit([Bind(Include = "ST_id,name,email,passwod,mobile,N_N,rule,approval,L_id,Dep_id,total,ST_image")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Dep_id = new SelectList(db.Departments, "Dep_id", "name", student.Dep_id);
     ViewBag.L_id   = new SelectList(db.Levels, "L_id", "L_id", student.L_id);
     return(View(student));
 }
Ejemplo n.º 14
0
 public ActionResult Edit([Bind(Include = "S_id,name,P_id,L_id,Dep_id,hours")] Subject subject)
 {
     if (ModelState.IsValid)
     {
         db.Entry(subject).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Dep_id = new SelectList(db.Departments, "Dep_id", "name", subject.Dep_id);
     ViewBag.L_id   = new SelectList(db.Levels, "L_id", "L_id", subject.L_id);
     ViewBag.P_id   = new SelectList(db.Professors, "P_id", "name", subject.P_id);
     return(View(subject));
 }
Ejemplo n.º 15
0
        public ActionResult Index(int id)
        {
            Incrementer inc = db.Incrementers.Find(id);

            if (inc.Count < 10)
            {
                inc.Count++;
            }

            if (ModelState.IsValid)
            {
                db.Entry(inc).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(View(db.Incrementers.Single()));
        }
Ejemplo n.º 16
0
        public ActionResult SetExam(FormCollection c, string ApplyProfile, string AddProfile, string sub, string num, Profile pf)
        {
            if (ApplyProfile != null)
            {
                //pf.Status = 1;
                List <Profile> li = db.Profiles.ToList();
                foreach (var item in li)
                {
                    item.Status = 0;
                }
                //  List<ProfileExam> profiles=db.Profiles.
                try
                {
                    var pro = db.Profiles.Where(x => x.Id == pf.Id).FirstOrDefault();
                    pro.Status = 1;
                    db.SaveChanges();
                }
                catch
                {
                    return(RedirectToAction("SetExam"));
                }
            }

            if (AddProfile != "")
            {
                Profile pro = new Profile();
                pro.Name   = AddProfile;
                pro.Status = 0;
                db.Profiles.Add(pro);
                db.SaveChanges();

                List <QuesCategory> lis = db.QuesCategories.ToList();
                Exam ex = new Exam();
                foreach (var item in lis)
                {
                    ex.Category  = item.Name;
                    ex.NoOfQues  = 0;
                    ex.CheckBox  = false;
                    ex.ProfileId = pro.Id;
                    db.Exams.Add(ex);
                    db.SaveChanges();
                }
            }

            int i = 0;

            if (sub != null)
            {
                int      t        = 0;
                string[] Check    = new string[100];
                var      ID       = c.GetValues("item.Exam.Id");
                var      CATEGORY = c.GetValues("item.Exam.Category");
                var      CHECKBOX = c.GetValues("item.Exam.CheckBox");
                var      Ques     = c.GetValues("item.Exam.NoOfQues");

                for (int k = 0; k < CHECKBOX.Length; k++)
                {
                    if (t < CHECKBOX.Length)
                    {
                        if (Convert.ToBoolean(CHECKBOX[t]).Equals(true))
                        {
                            Check[i] = CHECKBOX[t];
                            t        = t + 2;
                            i++;
                        }
                        else
                        {
                            Check[i] = CHECKBOX[t];
                            t        = t + 1;
                            i++;
                        }
                    }
                    else if (t == CHECKBOX.Length)
                    {
                        Check[i] = CHECKBOX[k];
                    }
                }
                t = 0;
                for (i = 0; i < ID.Count(); i++)
                {
                    Exam ex = db.Exams.Find(Convert.ToInt32(ID[i]));
                    ex.CheckBox = Convert.ToBoolean(Check[i]);
                    if (Check[i] == "true")
                    {
                        ex.NoOfQues = Convert.ToInt32(Ques[i]);
                        t           = t + Convert.ToInt32(Ques[i]);
                    }
                    db.Entry(ex).State = EntityState.Modified;
                }
                TempData["selectedQues"] = t;
                TempData.Keep();
                if (num == Convert.ToString(t))
                {
                    db.SaveChanges();
                    TempData["msg"] = "Saved successfully!";
                }
                else
                {
                    TempData["msg"] = "Set total is not equal to number of question!";
                }
            }



            return(RedirectToAction("SetExam"));
        }