Ejemplo n.º 1
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            HttpRequestBase request = controllerContext.HttpContext.Request;

            string prefix = ModelBinderHelpers.GetPrefixForCustomModelBinder(bindingContext);

            NewsItem newsItem = null;
            if (bindingContext.Model == null)
            {
                newsItem = new NewsItem();
                newsItem.ID = Guid.NewGuid();
            }
            else
            {
                newsItem = (NewsItem)bindingContext.Model;
            }

            newsItem.Name = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, prefix + "Name");
            newsItem.Description = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, prefix + "Description");
            newsItem.Body = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, prefix + "Body");

            newsItem.Created = DateTime.Now;

            OwnershipHelpers.SetOwner((IOwnableDO)newsItem, controllerContext.HttpContext.User);

            return newsItem;
        }
Ejemplo n.º 2
0
 public NewsItem SetNewsItemImage(NewsItem newsitem, byte[] data, UserCredentials userCredentials)
 {
     ListenTo.Shared.DO.Image image = ImageManager.HandleUploadedImage(data, userCredentials);
     newsitem.Image = image;
     this.Save(newsitem, userCredentials);
     return newsitem;
 }
Ejemplo n.º 3
0
 private void PrepareImageMetaData(NewsItem newsItem)
 {
     //Did the user upload an image?
     //If so, we want to display it...
     if (newsItem.Image != null)
     {
         ImageMetaData imageMetaData = (ImageMetaData)newsItem.Image;
         ViewData["Image"] = imageMetaData;
     }
 }
Ejemplo n.º 4
0
 public RedirectToRouteResult RedirectToNewsItem(NewsItem newsItem)
 {
     return RedirectToRoute(Routes.NEWSITEM_INDEX, new { id = newsItem.ID});
 }