public ActionResult Add(NewItemViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var item = new Item
             {
                 Id = model.Id,
                 ArticleId = model.ArticleId,
                 Body = model.Body,
                 Title = model.Title
             };
             DeleteCookies();
             DraftService.DeleteDraft(model.CookieToken);
             AddItem(item);
             return RedirectToAction("Details", "Article", new { id = model.ArticleId });
         }
     }
     catch (DataException)
     {
         ModelState.AddModelError("", Resources.Resources.UnableToSaveChanges);
     }
     return View(model);
 }
 private NewItemViewModel SetNewItemTextToCookies()
 {
     var cookieToken = Guid.NewGuid().ToString();
     var model = new NewItemViewModel { CookieToken = cookieToken };
     var cookie = new HttpCookie("_autosave")
     {
         Value = cookieToken,
         Expires = DateTime.Now.AddDays(1)
     };
     var titleCookie = new HttpCookie("_item-title")
     {
         Expires = DateTime.Now.AddDays(1)
     };
     Response.Cookies.Add(cookie);
     Response.Cookies.Add(titleCookie);
     return model;
 }
 private NewItemViewModel GetNewItemTextFromCookies()
 {
     var title = String.Empty;
     if (Request.Cookies["_item-title"] != null)
     {
         title = Request.Cookies["_item-title"].Value;
     }
     var cookie = Request.Cookies["_autosave"].Value;
     var model = new NewItemViewModel
     {
         CookieToken = cookie,
         Body = DraftService.GetDraft(cookie),
         Title = title
     };
     return model;
 }