Exemplo n.º 1
0
        public ActionResult CreateItem( CreateItemViewModel model )
        {
            if(Request.IsAjaxRequest())
            {
                if(!model.IsEmpty)
                {
                    return Json( _services.BuildItemToPrepend( _dataReader.GetItemById( _repository.CreateItem( model ) ) ) );
                }
                //TODO return Json EmptyModelError
            }

            return _repository.CreateItem( model ) != 0 ?
                (ActionResult)RedirectToAction( "Wall" ) : View( "_createItemError" ); // TODO Handle error
        }
Exemplo n.º 2
0
 public int CreateItem( CreateItemViewModel model )
 {
     using(MinyDataContext ctx = new MinyDataContext())
     {
         try
         {
             System.Nullable<int> CreatedItemId = ctx.sCreateItem( model.WallId, model.AuthorId, model.Note, model.Url, model.PicturePath, model.VideoPath, model.NbCol ).First();
             if(CreatedItemId.HasValue) { return CreatedItemId.Value; }
             return 0;
         }
         catch
         {
             return 0;
         }
     }
 }