public void CreateTaskList(User creatorUser, TaskList listData) { listData.Creator = creatorUser; _repository.Create(listData); _userListsRepo.Create(creatorUser.UniqueId, listData.Id, creatorUser.UniqueId); _listUsersRepo.Create(listData.Id, creatorUser.UniqueId, creatorUser.Name); }
Note CreateNote() { var taskList = new TaskList() { Name = "new list", Creator = _user, Users = new List<User>() { _user } }; _taskListManager.CreateTaskList(_user, taskList); Note n = new Note() { Name = "new note" }; _noteManager.CreateNote(_user, taskList.Id, _user.UniqueId, n); return n; }
public void Create(TaskList list) { list.Id = Guid.NewGuid().ToString(); if (!list.Users.Contains(list.Creator)) { list.Users.Add(list.Creator); } _lists.Add(list); }
public void CopyNoteTest() { var n1 = CreateNote(); var tl2 = new TaskList() { Name = "second list", Creator = _user, Users = new List<User>() { _user } }; _taskListManager.CreateTaskList(_user, tl2); var n2 = _taskManager.CopyNote(_user, tl2.Id, _user.UniqueId, n1); Assert.AreEqual(tl2.Id, n2.ParentList.Id); }
public NoteTest() { IoC.Configure(); _user = new User(); IUserManager um = ObjectFactory.GetInstance<IUserManager>(); um.CreateUser(_user); _taskList = new TaskList() { Name = "new list", Creator = _user, Users = new List<User>() { _user } }; _taskListManager = ObjectFactory.GetInstance<ITaskListManager>(); _taskListManager.CreateTaskList(_user, _taskList); _noteManager = ObjectFactory.GetInstance<INoteManager>(); }
// PUT /api/lists/{id} public void Put(string id, WebApiModel.TaskList list) { try { var userId = (Request.GetUserPrincipal().Identity as UserIdentity).UserId; var listData = new TaskList() { Name = list.name }; _manager.UpdateTaskList(userId, id, string.IsNullOrEmpty(list.creatorId)? userId : list.creatorId, listData); } catch (ObjectNotFoundException) { throw new HttpResponseException(HttpStatusCode.NotFound); } }
// POST /api/lists public HttpResponseMessage Post(WebApiModel.TaskList list) { var userId = (Request.GetUserPrincipal().Identity as UserIdentity).UserId; var listData = new TaskList() { Name = list.name }; _manager.CreateTaskList(new User { UniqueId = userId }, listData); list.id = listData.Id; var response = new HttpResponseMessage<WebApiModel.TaskList>(list) { StatusCode = HttpStatusCode.Created }; response.Headers.Location = new Uri(Request.RequestUri, "/api/lists/" + listData.Id + "/" + userId); return response; }
public void UpdateTaskList(string userId, string listId, string creatorId, TaskList listData) { var listUsers = _listUsersRepo.GetAll(listId); if (listUsers == null) { throw new ObjectNotFoundException(); } if (!listUsers.Any(u => u.UniqueId == userId)) { throw new NoPermissionException(); } _repository.Update(creatorId, listId, listData); foreach (var user in listUsers) { var notif = new Notification() { Task = listData, User = user, Type = Notification.NotificationType.Update }; _noticationMgr.CreateNotification(userId, notif); } }
public static void ConfigureTestEnv() { ObjectFactory.Initialize(ex => { ex.Scan(scan => { scan.TheCallingAssembly(); scan.WithDefaultConventions(); }); /* ex.For<INotificationProcessor>().Use<DummyNotificationProcessor>(); ex.For<IUserRepository>().Singleton().Use<PromptCloudNotes.InMemoryRepo.UserRepository>(); ex.For<ITaskListRepository>().Singleton().Use<PromptCloudNotes.InMemoryRepo.TaskListRepository>(); ex.For<INoteRepository>().Singleton().Use<PromptCloudNotes.InMemoryRepo.NoteRepository>(); ex.For<INotificationRepository>().Singleton().Use<PromptCloudNotes.InMemoryRepo.NotificationRepository>(); */ ex.For<IUserManager>().HttpContextScoped().Use<UserManager>(); ex.For<ITaskListManager>().HttpContextScoped().Use<TaskListManager>(); ex.For<INoteManager>().HttpContextScoped().Use<NoteManager>(); ex.For<ITaskManager>().HttpContextScoped().Use<TaskManager>(); ex.For<INotificationManager>().HttpContextScoped().Use<NotificationManager>(); }); DependencyResolver.SetResolver(new SmDependencyResolver(ObjectFactory.Container)); // generate dummy data in test environment var user = new User(); user.Name = "Sandra Fernandes"; var um = ObjectFactory.GetInstance<IUserManager>(); um.CreateUser(user); var list = new TaskList() { Name = "Dummy list", Description = "Dummy description" }; var tlm = ObjectFactory.GetInstance<ITaskListManager>(); tlm.CreateTaskList(user, list); var note = new Note() { Name = "note name", Description = "note description" }; var nm = ObjectFactory.GetInstance<INoteManager>(); nm.CreateNote(user, list.Id, user.UniqueId, note); }
public void MoveNoteTest() { var n1 = CreateNote(); string originalId = n1.Id; string originalList = n1.ParentList.Id; var tl2 = new TaskList() { Name = "second list", Creator = _user, Users = new List<User>() { _user } }; _taskListManager.CreateTaskList(_user, tl2); _taskManager.MoveNote(_user, tl2.Id, _user.UniqueId, n1.ParentList.Id, _user.UniqueId, n1); Assert.AreEqual(tl2.Id, n1.ParentList.Id); try { var n3 = _noteManager.GetNote(_user.UniqueId, originalList, originalId); Assert.Fail(); } catch (ObjectNotFoundException) // TODO set the correct exception { } }
TaskList CreateTaskList() { TaskList tl = new TaskList() { Name = "new list", Users = new List<User>() { _user } }; _taskListManager.CreateTaskList(_user, tl); return tl; }
public void CreateListTest() { TaskList tl = new TaskList() { Name = "new list", Users = new List<User>() { _user } }; _taskListManager.CreateTaskList(_user, tl); Assert.IsNotNull(tl.Id); }
public void Update(string user, string list, TaskList listData) { }
public void Update(TaskList list) { Name = list.Name; Description = list.Description; }
public TaskListEntity(TaskList list) : base(list.Creator.UniqueId, list.Id) { Update(list); }