Пример #1
0
 public ActionResult AddItem(Scrapbook model)
 {
     if (base.ModelState.IsValid)
     {
         string resource = Helper.GetResource("Feedback_AddedToScrapbook");
         if (base.User.Identity.IsAuthenticated)
         {
             string imageURL = (model.imageUrl != null) ? model.imageUrl : string.Empty;
             string itemDescription = (model.description != null) ? model.description : string.Empty;
             string sourceDescription = (model.sourceDescription != null) ? model.sourceDescription : model.sourceUrl;
             ScrapbookItem item = this.scrapbookrepository.InsertScrapbookItem(base.User.Identity.Name, imageURL, itemDescription, model.type, model.sourceUrl, sourceDescription);
             if (item == null)
             {
                 resource = Helper.GetResource("Feedback_NotAddedToScrapbook");
             }
             if (base.Request.IsAjaxRequest())
             {
                 var data = new {
                     success = item != null,
                     item = (item != null) ? item : null,
                     feedback = resource,
                     redirect = model.returnUrl
                 };
                 return base.Json(data);
             }
             base.Session.Add("feedback", resource);
         }
         return this.Redirect(model.returnUrl);
     }
     return this.Redirect(model.returnUrl);
 }
Пример #2
0
 public ActionResult Index()
 {
     Scrapbook model = new Scrapbook();
     if (base.User.Identity.IsAuthenticated)
     {
         model.items = (from x in this.scrapbookrepository.GetScrapbookItemsForUser(base.User.Identity.Name)
             orderby x.ItemDescription
             select x).ToList<ScrapbookItem>();
         return base.View(model);
     }
     string url = ConfigurationManager.AppSettings["Registration"] + "?returnUrl=" + base.Request.Url.PathAndQuery;
     base.Response.Redirect(url);
     return null;
 }