public ActionResult Create([Bind(Include = "Name,OrderId")] TeachingType model)
        {
            if (!LoginStatus())
            {
                return(RedirectToAction("Login", "Admins", null));
            }

            bool Exists = _db.TeachingTypes.Any(d => d.Name.Equals(model.Name));

            if (!Exists)
            {
                if (ModelState.IsValid)
                {
                    _db.TeachingTypes.Add(model);
                    _db.SaveChanges();
                    return(Json(""));
                }
                else
                {
                    return(Json("Model is not valid."));
                }
            }
            else
            {
                return(Json("Try another label name"));
            }
        }
예제 #2
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            TeachingType teachingType = db.TeachingTypes.Find(id);

            db.TeachingTypes.Remove(teachingType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create()
        {
            if (!LoginStatus())
            {
                return(RedirectToAction("Login", "Admins", null));
            }
            TeachingType model = new TeachingType()
            {
                Name = "", OrderId = (_db.TeachingTypes.Count() + 1)
            };

            return(View(model));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            if (!LoginStatus())
            {
                return(RedirectToAction("Login", "Admins", null));
            }

            TeachingType teachingType = _db.TeachingTypes.Find(id);

            _db.TeachingTypes.Remove(teachingType);
            _db.SaveChanges();
            return(Json(""));
        }
예제 #5
0
        // GET: TeachingTypes/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TeachingType teachingType = db.TeachingTypes.Find(id);

            if (teachingType == null)
            {
                return(HttpNotFound());
            }
            return(View(teachingType));
        }
        public ActionResult Edit(int?id)
        {
            if (!LoginStatus())
            {
                return(RedirectToAction("Login", "Admins", null));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TeachingType teachType = _db.TeachingTypes.Find(id);

            if (teachType == null)
            {
                return(HttpNotFound());
            }
            return(View(teachType));
        }
예제 #7
0
        public ActionResult Edit([Bind(Include = "TeachingTypeID,Name,Description")] TeachingTypeViewModel teachingTypeViewModel)
        {
            if (ModelState.IsValid)
            {
                TeachingType model = db.TeachingTypes.Find(teachingTypeViewModel.TeachingTypeID);

                model.Name        = teachingTypeViewModel.Name;
                model.Description = teachingTypeViewModel.Description;

                model.DateModified   = DateTime.Now;
                model.UserModifiedID = Guid.Parse(User.Identity.GetUserId());


                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(teachingTypeViewModel));
        }
예제 #8
0
        public ActionResult Create([Bind(Include = "Name,Description")] TeachingType teachingType)
        {
            if (ModelState.IsValid)
            {
                teachingType.TeachingTypeID = Guid.NewGuid();

                teachingType.DateCreated  = DateTime.Now;
                teachingType.DateModified = teachingType.DateCreated;

                teachingType.UserCreatedID  = Guid.Parse(User.Identity.GetUserId());
                teachingType.UserModifiedID = teachingType.UserCreatedID;

                db.TeachingTypes.Add(teachingType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(teachingType));
        }