Ejemplo n.º 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());
     }
 }
Ejemplo n.º 2
0
        public void CloneSimpleListTest()
        {
            var simpleListEntities    = new SimpleListEntities(Settings.Default.connectionString);
            var simpleListRespository = new SimpleListRepository(simpleListEntities);
            var userRespository       = new UserRepository(simpleListEntities);
            var user = userRespository.GetUser("bernard");
            var simpleListOriginalFromDb = simpleListRespository.GetSimpleLists(user.ID).FirstOrDefault();
            var simpleListCloned         = simpleListOriginalFromDb.Clone(user.ID, true, simpleListOriginalFromDb.Name + " - CLONED");

            simpleListRespository.AddSimpleList(simpleListCloned);
            var simpleListClonedFromDb =
                simpleListRespository.GetSimpleLists(user.ID).Where(l => l.Name == simpleListCloned.Name);

            Assert.IsNotNull(simpleListClonedFromDb);
        }
Ejemplo n.º 3
0
        public int CloneSimpleList(int simpleListIdOriginal, string simpleListNameNew, bool includeDoneSimpleListItems)
        {
            // Authenticate.
            var user = GetUserCredentials();

            if (user == null)
            {
                return(0);
            }

            _simpleListRepository = new SimpleListRepository();
            var simpleListToClone = _simpleListRepository.GetSimpleList(user.ID, simpleListIdOriginal);
            var simpleListCloned  = simpleListToClone.Clone(user.ID, includeDoneSimpleListItems, simpleListNameNew);

            return(_simpleListRepository.AddSimpleList(simpleListCloned));
        }
Ejemplo n.º 4
0
        public int CreateSimpleList(SimpleListViewModel simpleListViewModel)
        {
            // Authenticate.
            var user = GetUserCredentials();

            if (user == null)
            {
                return(0);
            }

            var mapper     = new Mapper();
            var simpleList = mapper.SimpleListViewModelToSimpleList(simpleListViewModel);

            simpleList.UserID     = user.ID;
            simpleList.DateAdded  = DateTime.Now;
            _simpleListRepository = new SimpleListRepository();
            return(_simpleListRepository.AddSimpleList(simpleList));
        }