Example #1
0
 public ActionResult Create(SimpleListModel simpleListModel)
 {
     try
     {
         if (User.Identity.IsAuthenticated)
         {
             _userRepository = new UserRepository();
             var user       = _userRepository.GetUserByUserName(User.Identity.Name);
             var simpleList = new SimpleList.DataModel.SimpleList();
             simpleList.Name       = simpleListModel.Name;
             simpleList.UserID     = user.ID;
             simpleList.DateAdded  = DateTime.Now;
             _simpleListRepository = new SimpleListRepository();
             _simpleListRepository.AddSimpleList(simpleList);
             return(RedirectToAction("Index"));
         }
         else
         {
             return(RedirectToAction("Index"));
         }
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Index()
        {
            InitializeViewBag("Simple list");
            var model = new SimpleListModel {
                Items = new List <string> {
                    "Alpha", "Beta", "Gamma"
                }
            };

            return(View(model));
        }
 public ActionResult AddItem(SimpleListModel model)
 {
     model.AddItem();
     return(Json(model));
 }