public ActionResult DeleteConfirmed(int id)
        {
            SelectSub selectsub = db.SelectSub.Find(id);

            db.SelectSub.Remove(selectsub);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #2
0
        /// <summary>
        /// 更新ボタンの処理
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> OnPostUpdateAsync(string mainName, string subName, string fileName, string razorScript)
        {
            // Razorが空だったら拒否
            if (string.IsNullOrWhiteSpace(razorScript))
            {
                ViewData["Error"] = "ちょっとぐらいなにか書け。";
                return(await OnGetAsync());
            }

            // メインを決定する
            var main = SelectMain;

            if (!string.IsNullOrWhiteSpace(mainName))
            {
                main = mainName;
            }
            if (string.IsNullOrWhiteSpace(main))
            {
                ViewData["Error"] = "メインの名前が分からん。";
                return(await OnGetAsync());
            }

            // サブを決定する
            var sub = SelectSub;

            if (!string.IsNullOrWhiteSpace(subName))
            {
                sub = subName;
            }
            else
            {
                sub = SelectSub.Split('#')[1];
            }
            if (string.IsNullOrWhiteSpace(sub))
            {
                ViewData["Error"] = "サブの名前が分からん。";
                return(await OnGetAsync());
            }

            // ファイルを決定する
            if (string.IsNullOrWhiteSpace(RazorId) && string.IsNullOrWhiteSpace(fileName))
            {
                ViewData["Error"] = "ファイル名が分からん。";
                return(await OnGetAsync());
            }

            var result = await _mediator.Send(new UpdateQuery {
                RazorId     = RazorId,
                MainName    = main,
                SubName     = sub,
                FileName    = fileName,
                RazorScript = razorScript
            });

            ViewData["Message"] = result.Result;
            return(await OnGetAsync());
        }
        //
        // GET: /SelectSub/Details/5

        public ActionResult Details(int id = 0)
        {
            SelectSub selectsub = db.SelectSub.Find(id);

            if (selectsub == null)
            {
                return(HttpNotFound());
            }
            return(View(selectsub));
        }
 public ActionResult Edit(SelectSub selectsub)
 {
     if (ModelState.IsValid)
     {
         db.Entry(selectsub).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.StuID = new SelectList(db.Student, "StuID", "StuName", selectsub.StuID);
     ViewBag.SubID = new SelectList(db.Sub, "SubID", "SubName", selectsub.SubID);
     return(View(selectsub));
 }
        //
        // GET: /SelectSub/Edit/5

        public ActionResult Edit(int id = 0)
        {
            SelectSub selectsub = db.SelectSub.Find(id);

            if (selectsub == null)
            {
                return(HttpNotFound());
            }
            ViewBag.StuID = new SelectList(db.Student, "StuID", "StuName", selectsub.StuID);
            ViewBag.SubID = new SelectList(db.Sub, "SubID", "SubName", selectsub.SubID);
            return(View(selectsub));
        }
        public ActionResult Create(SelectSub selectsub)
        {
            if (ModelState.IsValid)
            {
                db.SelectSub.Add(selectsub);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StuID = new SelectList(db.Student, "StuID", "StuName", selectsub.StuID);
            ViewBag.SubID = new SelectList(db.Sub, "SubID", "SubName", selectsub.SubID);
            return(View(selectsub));
        }
Exemple #7
0
        public ActionResult kskcselect(string subID)
        {
            try
            {
                string[] subIDs;
                subIDs = subID.Split(',');
                Sub       subss = new Sub();
                Student   stu   = new Student();
                SelectSub ss    = new SelectSub();
                string    num   = Request.Cookies["studentInfo"]["studentNum"];
                int       stuid = bLLStudent.Details(c => c.StuNum == num).FirstOrDefault().StuID;
                stu = bLLStudent.Details(c => c.StuNum == num).FirstOrDefault();
                string msg = "";
                for (int i = 0; i < subIDs.Length; i++)
                {
                    stu = null;
                    int nowdi = int.Parse(subIDs[i]);
                    subss = bllSub.Details(c => c.SubID == nowdi).FirstOrDefault();

                    if (bllselectsub.Details(c => c.StuID == stuid && c.SubID == nowdi).Count() != 0)
                    {
                        msg = "您已选择这门课程,不允许重复选择!~";
                    }
                    else
                    if (subss.ClassPeople < subss.NeedPeople)
                    {
                        int peopels = subss.ClassPeople + 1;
                        subss.ClassPeople = peopels;
                        ss.StuID          = stuid;
                        ss.SubID          = nowdi;
                        bllselectsub.Add(ss);
                        bllSub.Edit(subss);
                        bllselectsub.SaveChange();
                        bllSub.SaveChange();
                        msg = "ok";
                    }
                    else
                    {
                        msg = "此课程选课人数已满!,不允许选课";
                    }
                }
                return(Content(msg));
            }
            catch {
                return(Content("没有相应的数据,请刷新重试!"));
            }
        }
Exemple #8
0
        /// <summary>
        /// 削除ボタンの処理
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> OnPostDeleteAsync()
        {
            // メインを決定する
            if (string.IsNullOrWhiteSpace(SelectMain))
            {
                ViewData["Error"] = "何も消さなくて良いのだな?";
                return(await OnGetAsync());
            }

            var result = await _mediator.Send(new DeleteQuery
            {
                RazorId  = RazorId,
                MainName = SelectMain,
                SubName  = SelectSub?.Split('#')[1]
            });

            ViewData["Message"] = result.Result;
            return(await OnGetAsync());
        }