示例#1
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tag tag = db.GetTagById(User, id.Value);

            if (tag == null)
            {
                return(HttpNotFound());
            }
            return(View(tag));
        }
示例#2
0
        // GET: /Task/AddTag/5?tagid=1
        public ActionResult AddTag(int?id, int?tagid)
        {
            if (id == null || tagid == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var task = db.GetTaskById(User, id.Value);
            var tag  = db.GetTagById(User, tagid.Value);

            if (task == null || tag == null)
            {
                return(HttpNotFound());
            }

            if (task.Tags.Where(t => t.ID == tag.ID).FirstOrDefault() == null)
            {
                task.Tags.Add(tag);
            }
            db.SaveChanges();

            return(Redirect(Request.GetReferrerUrlOrCurrent()));
        }