コード例 #1
0
        public ToDoListTaskResponse CreateToDoListTask(int listId, ToDoListTaskRequest item)
        {
            try
            {
                _log.Debug("Create task");
                _toDoListManager.AddTaskToList(listId, Mapper.Map <ToDoListTask>(item));
                _log.Debug("Send result success create task");
                var task = _toDoListManager.GetListItemDetail(listId).Tasks.LastOrDefault(u => u.Text == item.Text &&
                                                                                          u.IsCompleted == item.IsCompleted && u.CreateDate == item.CreateDate);
                return(new ToDoListTaskResponse
                {
                    StatusCode = 201,
                    Message = "SUCCESS",
                    Data = task //_toDoListManager.GetListItemDetail(listId).Tasks.Last()
                });             //_toDoListManager.GetListItemDetail(listId).Tasks.Last() }; //item

                _log.Info("Created task");
            }
            catch (ToDoListException ex)
            {
                _log.Error(ex);
                return(new ToDoListTaskResponse {
                    Message = ex.Message
                });
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                return(new ToDoListTaskResponse {
                    Message = ex.Message
                });
            }
        }
コード例 #2
0
        public ToDoListTaskResponse CreateToDoListTask(int listId, ToDoListTaskRequest item)
        {
            try
            {
                _log.Debug("Create task");
                _toDoListManager.AddTaskToList(listId, Mapper.Map <ToDoListTask>(item));
                _log.Debug("Send result success create task");
                return(new ToDoListTaskResponse {
                    StatusCode = 201, Message = "SUCCESS", Data = item
                });

                _log.Info("Created task");
            }
            catch (ToDoListException ex)
            {
                _log.Error(ex);
                return(new ToDoListTaskResponse {
                    Message = ex.Message
                });
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                return(new ToDoListTaskResponse {
                    Message = ex.Message
                });
            }
        }