예제 #1
0
        public ActionResult ClassNoti(string ClassNotiText, string ClassNotiAttribute, string[] checkbox)
        {
            try
            {
                if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Teacher))
                {
                    return(RedirectToAction("PermitionEr", "Error"));
                }

                string str = null;
                for (int i = 0; i < checkbox.Length; i++)
                {
                    ClassNoti a = new ClassNoti()
                    {
                        ClassNotiAttribute = ClassNotiAttribute,
                        ClassNoticlass     = checkbox[i],
                        ClassNotiText      = ClassNotiText,
                        ClassNotiTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                    };
                    db3.ClassNotis.Add(a);
                }
                db3.SaveChanges();
                return(View());
            }
            catch
            {
                return(RedirectToAction("LoginEr", "Error"));
            }
        }
예제 #2
0
        // POST: odata/ClassNotis
        public IHttpActionResult Post(ClassNoti classNoti)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ClassNotis.Add(classNoti);
            db.SaveChanges();

            return(Created(classNoti));
        }
예제 #3
0
        // DELETE: odata/ClassNotis(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            ClassNoti classNoti = db.ClassNotis.Find(key);

            if (classNoti == null)
            {
                return(NotFound());
            }

            db.ClassNotis.Remove(classNoti);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #4
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta <ClassNoti> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ClassNoti classNoti = db.ClassNotis.Find(key);

            if (classNoti == null)
            {
                return(NotFound());
            }

            patch.Patch(classNoti);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClassNotiExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(classNoti));
        }