No Metadata Documentation available.
Наследование: ObjectContext
Пример #1
0
        public ActionResult Edit(string title, FormCollection collection)
        {
            Article article = null;
            ViewData["success"] = false;
            WikiDb WikiDb = new WikiDb();

            //If we cant check session or session username isnt set, this user cannot edit article
            try {
                if (Session["username"] == null) {
                    ViewData["error_message"] = "You have to be logged in to edit an article.";
                    return View(new Article(title));
                }
            } catch {
                ViewData["error_message"] = "You have to be logged in to edit an article.";
                return View(new Article(title));
            }

            try
            {
                article = new Article(title);
            }
            catch (ArticleDoesNotExistException)
            {
                try
                {

                    //Articles newArticle = new Articles { Title = collection["Title"], Body = collection["Body"] };
                    Articles newArticle = new Articles();
                    newArticle.Title = collection["Title"];
                    newArticle.Body = collection["Body"];
                    WikiDb.AddToArticles(newArticle);
                    WikiDb.SaveChanges();

                    //ViewData["debug"] += collection["Id"];
                    RedirectToAction("Details/" + title);
                }
                catch (Exception)
                {
                    ViewData["debug"] += "article doesnt exist and cant redirect";
                    return View(new Article());
                }
            }

            if (article == null)
            {
                return View(new Article());
            }

            UpdateModel(WikiDb.Articles.Single(a => a.Id == article.Id), collection.ToValueProvider());
            WikiDb.SaveChanges();
            ViewData["success"] = true;

            return View(new Article(title));
        }
Пример #2
0
        public ActionResult Create(FormCollection collection)
        {
            /*
            try
            {*/

                WikiDb WikiDb = new WikiDb();

                return View();
                //return RedirectToAction("View");
                /*
            }
            catch (Exception e)
            {
                e.
            }*/
        }