コード例 #1
0
        public ActionResult DoDeduction(string ID)
        {
            int res = Check();

            if (res == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else if (res == 2)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                CommonWork();

                TeacherRewardEntities db = new TeacherRewardEntities();
                DeducViewModel        this_unfortunate_teacher_agiain = new DeducViewModel();
                this_unfortunate_teacher_agiain.user = db.Users.Where(x => x.ID == ID).FirstOrDefault();

                return(View(this_unfortunate_teacher_agiain));
            }
        }
コード例 #2
0
        public ActionResult DoDeduction(string ID, DeducViewModel form)
        {
            if (ID == null)
            {
                return(RedirectToAction("Error", "Admin"));
            }

            var db           = new TeacherRewardEntities();
            var newDeduction = new Deduction();

            newDeduction.ID              = ID;
            newDeduction.SuperComment    = form.deduction.SuperComment;
            newDeduction.Supervisior     = form.deduction.Supervisior;
            newDeduction.Accident        = form.deduction.Accident;
            newDeduction.AccidentComment = form.deduction.AccidentComment;

            try {
                db.Deduction.Add(newDeduction);
                db.SaveChanges();
                return(RedirectToAction("ShowDeduction", "Admin"));
            } catch (Exception) {
                return(RedirectToAction("Error", "Admin"));
            }
        }