Esempio n. 1
0
        public ActionResult Create([Bind(Include = "ID,LastName,FirstName,FatherName,TotalIncome,IncomeEvidence,StudentAddress,StudentCity,StudentProvince,ContactNumber,DateOfBirth")] Students students)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(students);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(students));
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "ID,SchoolName,StudentAddress,StudentCity,StudentProvince,ContactNumber1,ContactNumber2,TotalEnrollment,FocalPersonName,FocalPersonContact")] School school)
        {
            if (ModelState.IsValid)
            {
                db.Schools.Add(school);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(school));
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "Id,Email,Password,Role,Avatar")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Id = new SelectList(db.UserInfors, "Id", "Name", user.Id);
            return(View(user));
        }
 public ActionResult CreateQiuzz(Quizz newQuizz)
 {
     using (EducationDBContext db = new EducationDBContext())
     {
         db.Quizzs.Add(newQuizz);
         db.SaveChanges();
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult CreateLession(Lession newLession)
 {
     using (EducationDBContext db = new EducationDBContext())
     {
         db.Lessions.Add(newLession);
         db.SaveChanges();
     }
     return(RedirectToAction("Index", "Home"));
 }
 public ActionResult CreateSubject(Subject newSubject)
 {
     using (EducationDBContext db = new EducationDBContext())
     {
         db.Subjects.Add(newSubject);
         db.SaveChanges();
     }
     //dang loi o line 71 phan View khi get select item
     return(RedirectToAction("Index", "Home"));
 }
Esempio n. 7
0
        public bool Form(Candidate c, List <string> Lang, List <Education> edu, List <Employeer> emp, List <string> Skills, List <Reference> refer)
        {
            try
            {
                c.UploadResume = file_path;
                CAND.Candidates.Add(c);
                CAND.SaveChanges();
                var c_id = c.ID;
                foreach (string lang in Lang)
                {
                    Language l = new Language()
                    {
                        CID = c_id, Lang = lang
                    };
                    LANG.Languages.Add(l);
                    LANG.SaveChanges();
                }

                foreach (Education ed in edu)
                {
                    ed.CID = c_id;
                    EDU.Educations.Add(ed);
                    EDU.SaveChanges();
                }

                foreach (Employeer em in emp)
                {
                    em.CID = c_id;
                    EMP.Employeers.Add(em);
                    EMP.SaveChanges();
                }
                foreach (string s in Skills)
                {
                    Skill sk = new Skill()
                    {
                        CID = c_id, Skills = s
                    };
                    SKILL.Skills.Add(sk);
                    SKILL.SaveChanges();
                }
                foreach (Reference r in refer)
                {
                    r.CID = c_id;
                    REF.References.Add(r);
                    REF.SaveChanges();
                }
                file.SaveAs(file_path);

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
        public ActionResult CreateCourse(Course newCourse)
        {
            using (EducationDBContext db = new EducationDBContext())
            {
                //get data then check data // then create and forward
                db.Courses.Add(newCourse);
                db.SaveChanges();
            }

            //forward value of id to create subject
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 9
0
 public ActionResult Content()
 {
     int id = Convert.ToInt32(Request["Id"]);
     var content = (from s in db.Lessions where s.Id == id select s).ToList();
     foreach (var contents in content)
     {
         ViewBag.contents = content;
         contents.View++;
     }
     db.SaveChanges();
     ViewBag.contents = content;
     return View();
 }
Esempio n. 10
0
        public ActionResult Subject(int subjecId)
        {
            //get new rate
            int UserRate = Convert.ToInt32(Request["new_rating_star"]);
            //cal and response: totalrate+1

            //get value
            var     recordeSubjectId = (from s in db.Subjects where s.Id == subjecId select s).ToList();
            Subject currentSubject   = recordeSubjectId[0];

            double newSubjectRate = Convert.ToDouble((currentSubject.Total_rate * currentSubject.Rate + UserRate) / (currentSubject.Total_rate + 1));

            //update
            var result = db.Subjects.SingleOrDefault(b => b.Id == currentSubject.Id);

            if (result != null)
            {
                result.Rate       = newSubjectRate;
                result.Total_rate = result.Total_rate + 1;
                db.SaveChanges();
            }
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 11
0
        public ActionResult Register(string name, string email, int mobile, string pass)
        {
            //moi lan tao moi la phai tao moi ca 2 bang
            using (EducationDBContext db = new EducationDBContext())
            {
                User principal = new User()
                {
                    Email    = email,
                    Password = pass,
                    Role     = 2,
                };

                UserInfor ui = new UserInfor()
                {
                    Name  = name,
                    Phone = mobile
                };
                ui.Id = db.Users.Add(principal).Id;
                db.UserInfors.Add(ui);
                db.SaveChanges();
                return(View("Contact"));
            }
        }
Esempio n. 12
0
        public ActionResult AfterSubmit(List<AnswerOnSubmitDTO> data, int id, string time)
        {
            int userId = Convert.ToInt32(Session["id"]);
            int correctAns = 0;
            double pointTotalCorrect = 0;
            double pointTotal = 0;
            data = data != null ? data : new List<AnswerOnSubmitDTO>();
            PointAfterSubmitDTO pointAfter;
            List<ResultDTO> ResultDTO = new List<ResultDTO>();
            double timeQuizz;
            double timeRemaind;
            double timeDo;
            List<QuestionsGivenDTO> lstDTO= new List<QuestionsGivenDTO>();

            //data handle
            using (EducationDBContext db = new EducationDBContext())
            {

                //get list ques
                var lst = (from qs in db.Questions where qs.CurrentQuizzId == id orderby qs.Id select qs).ToList();
                 lstDTO = AutoMap.Mapper.Map<List<QuestionsGivenDTO>>(lst);

                //time handle
                string[] str = time.Split(':');
                timeQuizz = (from q in db.Quizzs where q.Id == id select q).First().time * 60*60;
                timeRemaind = int.Parse(str[0])*60 + int.Parse(str[1]);
                timeDo = timeQuizz - timeRemaind;
                int currentIdQues = -1;
                //check question
                foreach (AnswerOnSubmitDTO item in data)
                {
                    var ansCorrect = (from an in db.Answers where an.CurrentQuestionId == item.Ques && an.IsCorrect select an).First();
                    double? point = (from q in db.Questions where q.Id == item.Ques select q).FirstOrDefault().Point;
                    if(currentIdQues != item.Ques)
                    {
                        pointTotal += point.HasValue ? point.Value : 0;
                        currentIdQues = item.Ques;
                    }
                    if (ansCorrect.Id == item.Ans)
                    {
                        pointTotalCorrect += point.HasValue ? point.Value : 0;
                        correctAns += 1;
                    }
                    ResultDTO.Add(new ResultDTO()
                    {
                        AnsChoosed = item.Ans,
                        CorrectAns = ansCorrect.Id,
                        QuesId = item.Ques,
                        QuizzId = id,
                    });
                }
                UserInfor user = (from u in db.UserInfors where u.Id == userId select u).FirstOrDefault();
                Quizz quizz = (from q in db.Quizzs where q.Id == id select q).FirstOrDefault();
                pointAfter = new PointAfterSubmitDTO()
                {
                    Quizz = quizz,
                    Score = pointTotalCorrect,
                    UserInfor = user,
                    CorrectAnswer = correctAns
                };
                Point score = (from p in db.points where p.UserInfor.Id == userId && p.Quizz.Id == id select p).FirstOrDefault();
                if (score != null)
                {
                    score.CorrectAnswer = pointAfter.CorrectAnswer;
                    score.Quizz = pointAfter.Quizz;
                    score.Score = pointAfter.Score;
                    score.UserInfor = pointAfter.UserInfor;
                }
                else
                {
                    db.points.Add(AutoMap.Mapper.Map<Point>(pointAfter));
                }
                db.SaveChanges();
            }
            return Json(new
            {
                lisQues=lstDTO,
                data = ResultDTO,
                timetotal = timeQuizz,
                timeDo = timeDo,
                point= pointTotalCorrect,
                pointTotal= pointTotal
            },
            JsonRequestBehavior.AllowGet) ;
        }