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 void GetSimpleListByIdTest() { SimpleListRepository target = new SimpleListRepository(); int simpleListId = 1; Infostructure.SimpleList.DataModel.Models.SimpleList actual; actual = target.GetSimpleList(_userForTest.ID, simpleListId); Assert.IsNotNull(actual); }
// // 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")); } }
public int DeleteSimpleList(int simpleListId) { // Authenticate. var user = GetUserCredentials(); if (user == null) { return(0); } _simpleListRepository = new SimpleListRepository(); return(_simpleListRepository.DeleteSimpleList(user.ID, simpleListId)); }
// // 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")); } }
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); }
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()); }
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)); }
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)); }
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)); }
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)); }