public ToDoListItemResponse CreateToDoListItem(ToDoListItemRequest item) { try { _log.Debug("Create list"); _toDoListManager.CreateList(Mapper.Map <ToDoListItem>(item)); _log.Debug("Send result success create list"); var list = _toDoListManager.GetListItems().LastOrDefault(u => u.Name == item.Name && u.CreateDate == item.CreateDate); return(new ToDoListItemResponse { StatusCode = 201, Message = "SUCCESS", Data = list }); //item }; _log.Info("Created list"); } catch (ToDoListException ex) { _log.Error(ex); return(new ToDoListItemResponse { Message = ex.Message }); } catch (Exception ex) { _log.Error(ex); return(new ToDoListItemResponse { Message = ex.Message }); } }
public ToDoListItemResponse CreateToDoListItem(ToDoListItemRequest item) { try { _log.Debug("Create list"); _toDoListManager.CreateList(Mapper.Map <ToDoListItem>(item)); _log.Debug("Send result success create list"); return(new ToDoListItemResponse { StatusCode = 201, Message = "SUCCESS", Data = item }); _log.Info("Created list"); } catch (ToDoListException ex) { _log.Error(ex); return(new ToDoListItemResponse { Message = ex.Message }); } catch (Exception ex) { _log.Error(ex); return(new ToDoListItemResponse { Message = ex.Message }); } }
public async Task <int> CreateTodoList(TodoListInput input) { var finishOnHighPriority = false; var finishOnAllPriority = false; //Resolve configuration switch (input.TaskConfig) { case "High": finishOnHighPriority = true; break; case "All": finishOnAllPriority = true; break; } var project = _projectManager.GetProject(input.ProjectId); var list = ToDoList.CreateList(input.Name, input.Observations, input.StartDate, input.EndDate, 0, finishOnAllPriority, finishOnHighPriority, project, 0, input.AllowTodoSelection, null); var id = _toDoListManager.CreateList(list); var projectMembers = await _membersManager.GetAllMembers(input.ProjectId); foreach (var projectMember in projectMembers) { await _projectNotificationSubscriptionService.RegisterToGeneralNotifications(project, projectMember.Id); } //Overkill and unnecessary //var listMembers = input.Members.Select(memberInput => new UserTaskListIdentity() //{ // IsLeader = memberInput.Leader, // TaskListId = id, // UserId = memberInput.UserId //}).ToList(); //_toDoListManager.AddUsersToList(id, listMembers); //Register the members to all the notifications of the current list //then notifies all //await ProcessNotifications(id,listMembers); return(id); }