예제 #1
0
        public async Task Start(int id)
        {
            var start = DateTime.Now;

            TodoListData item = await context.TodoListData.FindAsync(id);

            item.Start = start;

            context.TodoListData.Update(item);

            await context.SaveChangesAsync();
        }
예제 #2
0
        public async Task Stop(int id)
        {
            TodoListData item = await context.TodoListData.FindAsync(id);

            var spendTime = DateTime.Now - item.Start;

            var spendTimePlus = item.SpendTime + spendTime;

            item.SpendTime = spendTimePlus;

            context.TodoListData.Update(item);

            await context.SaveChangesAsync();
        }
예제 #3
0
        public async Task CreateTaskForUser(TodoListViewModel item)
        {
            TodoListData items = new TodoListData
            {
                Content            = item.Content,
                Datetime           = item.Datetime,
                ApplicationUsersId = item.ApplicationUsersId,
                Priority           = item.Priority,
                LeadTime           = item.LeadTime
            };

            context.TodoListData.Add(items);

            await context.SaveChangesAsync();
        }
예제 #4
0
        public SecondaryType(TodoListData data)
        {
            Name = "SecondaryTodo";

            Field(h => h.Id).Description("The id of the Secondary Task.");
            Field(h => h.Name, nullable: true).Description("The name of the Secondary task.");
            Field(h => h.Description, nullable: true).Description("The descrition of the Secondary task.");

            Field <ListGraphType <TodoItemInterface> >(
                "relatedto",
                resolve: context => data.GetRelatedTask(context.Source)
                );

            Interface <TodoItemInterface>();
        }
예제 #5
0
        public ImportantType(TodoListData data)
        {
            Name        = "ImportantTodo";
            Description = "This is an important task.";

            Field(h => h.Id).Description("The id of the Important Task.");
            Field(h => h.Name, nullable: true).Description("The name of the Important task.");
            Field(h => h.Description, nullable: true).Description("The descrition of the Important task.");

            Field <ListGraphType <TodoItemInterface> >(
                "relatedto",
                resolve: context => data.GetRelatedTask(context.Source)
                );

            Field <PriorityEnum>("priority", "The priority of the tasks");

            Interface <TodoItemInterface>();
        }
        protected Activity BuildTodoCard(
            ITurnContext turnContext,
            string tempId,
            List <TaskItem> todos,
            int allTasksCount,
            string listType)
        {
            var tokens = new StringDictionary()
            {
                { "taskCount", allTasksCount.ToString() },
                { "listType", listType },
            };

            var showTodoListData = new TodoListData
            {
                Title       = string.Format(ToDoStrings.CardTitle, listType),
                TotalNumber = allTasksCount > 1 ? string.Format(ToDoStrings.CardMultiNumber, allTasksCount.ToString()) : string.Format(ToDoStrings.CardOneNumber, allTasksCount.ToString())
            };

            List <Card> todoItems = new List <Card>();

            int  index   = 0;
            bool useFile = Channel.GetChannelId(turnContext) == Channels.Msteams;

            foreach (var todo in todos)
            {
                todoItems.Add(new Card(GetDivergedCardName(turnContext, "ShowTodoItem"), new TodoItemData
                {
                    CheckIconUrl = todo.IsCompleted ? (useFile ? GetImageUri(IconImageSource.CheckIconFile) : IconImageSource.CheckIconSource) : (useFile ? GetImageUri(IconImageSource.UncheckIconFile) : IconImageSource.UncheckIconSource),
                    Topic        = todo.Topic
                }));

                index++;
            }

            var cardReply = ResponseManager.GetCardResponse(
                tempId,
                new Card(GetDivergedCardName(turnContext, "ShowTodoCard"), showTodoListData),
                tokens,
                "items",
                todoItems);

            return(cardReply);
        }
        protected Activity BuildTodoCard(
            string tempId,
            List <TaskItem> todos,
            int allTasksCount,
            string listType)
        {
            var tokens = new StringDictionary()
            {
                { "taskCount", allTasksCount.ToString() },
                { "listType", listType },
            };

            var showTodoListData = new TodoListData
            {
                Title       = string.Format(ToDoStrings.CardTitle, listType),
                TotalNumber = allTasksCount > 1 ? string.Format(ToDoStrings.CardMultiNumber, allTasksCount.ToString()) : string.Format(ToDoStrings.CardOneNumber, allTasksCount.ToString())
            };

            List <Card> todoItems = new List <Card>();

            int index = 0;

            foreach (var todo in todos)
            {
                todoItems.Add(new Card("ShowTodoItem", new TodoItemData
                {
                    CheckIconUrl = todo.IsCompleted ? IconImageSource.CheckIconSource : IconImageSource.UncheckIconSource,
                    Topic        = todo.Topic
                }));

                index++;
            }

            var cardReply = ResponseManager.GetCardResponse(
                tempId,
                new Card("ShowTodoCard", showTodoListData),
                tokens,
                "items",
                todoItems);

            return(cardReply);
        }
예제 #8
0
        public async Task <TodoListData> CreateTaskForUser(TodoListViewModel item, string userId)
        {
            var currentUser = await context.Users.Where(x => x.Id == userId).FirstOrDefaultAsync();

            TodoListData items = new TodoListData
            {
                Content            = item.Content,
                Datetime           = item.Datetime,
                ApplicationUsersId = currentUser.Id.ToString(),
                Priority           = item.Priority,
                LeadTime           = item.LeadTime
            };


            context.TodoListData.Add(items);

            await context.SaveChangesAsync();

            return(items);
        }
예제 #9
0
 public async Task DeleteTask(TodoListData item)
 {
     context.TodoListData.Remove(item);
     await context.SaveChangesAsync();
 }
예제 #10
0
        public async Task <TodoListData> GetTaskId(int id)
        {
            TodoListData item = await context.TodoListData.FindAsync(id);

            return(item);
        }