예제 #1
0
        public ActionResult AddClass()
        {
            ViewBag.TitleName = "Add Class";
            var days = new AddClassForm();

            return(View(days));
        }
예제 #2
0
        public ActionResult EditClass(int id)
        {
            ViewBag.TitleName = "Edit Class";
            var Class = _context.Classes.SingleOrDefault(c => c.Id == id);

            if (Class == null)
            {
                return(HttpNotFound());
            }
            else
            {
                var viewModel = new AddClassForm {
                    Class = Class
                };


                return(View("AddClass", viewModel));
            }
        }
예제 #3
0
        public ActionResult Save(AddClassForm classes)
        {
            if (classes.Class.Id == 0)
            {
                _context.Classes.Add(classes.Class);
            }

            else
            {
                var classInDb = _context.Classes.Single(c => c.Id == classes.Class.Id);

                classInDb.Name      = classes.Class.Name;
                classInDb.Day       = classes.Class.Day;
                classInDb.StartTime = classes.Class.StartTime;
            }

            _context.SaveChanges();

            return(RedirectToAction("Index", "Classes"));
        }
        private void buttonAddClass_Click(object sender, EventArgs e)
        {
            AddClassForm newForm = new AddClassForm(currentCharacter);

            newForm.Show();
        }