コード例 #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());
     }
 }
コード例 #2
0
        public void GetSimpleListByIdTest()
        {
            SimpleListRepository target = new SimpleListRepository();
            int simpleListId            = 1;

            Infostructure.SimpleList.DataModel.Models.SimpleList actual;
            actual = target.GetSimpleList(_userForTest.ID, simpleListId);
            Assert.IsNotNull(actual);
        }
コード例 #3
0
        //
        // GET: /SimpleList/

        public ActionResult Index()
        {
            if (User.Identity.IsAuthenticated)
            {
                _simpleListRepository = new SimpleListRepository();
                var simpleLists = _simpleListRepository.GetSimpleListsByUserName(User.Identity.Name);
                return(View("Index", simpleLists));
            }
            else
            {
                return(View("Index"));
            }
        }
コード例 #4
0
        public int DeleteSimpleList(int simpleListId)
        {
            // Authenticate.
            var user = GetUserCredentials();

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

            _simpleListRepository = new SimpleListRepository();
            return(_simpleListRepository.DeleteSimpleList(user.ID, simpleListId));
        }
コード例 #5
0
        //
        // GET: /Lists/{simpleListId}/ListItems

        public ActionResult Index(int simpleListId)
        {
            if (User.Identity.IsAuthenticated)
            {
                _simpleListRepository = new SimpleListRepository();
                var simpleList = _simpleListRepository.GetSimpleListById(simpleListId);
                return(View("Index", simpleList));
            }
            else
            {
                return(View("Index"));
            }
        }
コード例 #6
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);
        }
コード例 #7
0
        public List <Models.SimpleListModel> GetSimpleLists(string userName, string password)
        {
            _simpleListRepository = new SimpleListRepository();
            var simpleLists = _simpleListRepository.GetSimpleLists(userName, password);

            return((from simpleList in simpleLists
                    select new Models.SimpleListModel
            {
                ID = simpleList.ID,
                UserID = simpleList.UserID,
                Name = simpleList.Name,
                AllDone = simpleList.AllDone,
                DateAdded = simpleList.DateAdded
            }).ToList());
        }
コード例 #8
0
        public SimpleListViewModel GetSimpleList(int simpleListId)
        {
            // Authenticate.
            var user = GetUserCredentials();

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

            var mapper = new Mapper();

            _simpleListRepository = new SimpleListRepository();
            return(mapper.SimpleListToSimpleListViewModel(_simpleListRepository.GetSimpleList(user.ID, simpleListId), true));
        }
コード例 #9
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));
        }
コード例 #10
0
        public IEnumerable <SimpleListViewModel> GetSimpleLists(bool populateSubStructures)
        {
            // Authenticate.
            var user = GetUserCredentials();

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

            var mapper = new Mapper();

            _simpleListRepository = new SimpleListRepository();
            var simpleLists = _simpleListRepository.GetSimpleLists(user.ID);

            return(mapper.SimpleListsToSimpleListViewModels(simpleLists, populateSubStructures));
        }
コード例 #11
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));
        }