コード例 #1
0
        public BllTask Update(BllTask entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            var task = context.Set <Task>().FirstOrDefault(a => a.Id == entity.Id);

            if (task == null)
            {
                return(null);
            }

            context.Set <Task>().Attach(task);

            if (entity.ToDoId != null)
            {
                task.ToDoId = entity.ToDoId;
            }
            task.IsCompleted = entity.IsCompleted;
            if (entity.Name != null)
            {
                task.Name = entity.Name;
            }
            task.IsDeleted = entity.IsDeleted;

            context.SaveChanges();

            return(task.GetBllEntity());
        }
コード例 #2
0
        public static void ActionsInitialize(IActionRepository actionRepository, ITaskRepository repository)
        {
            var result = actionRepository.GetAll();

            if (result != null && result.Count() != 0)
            {
                foreach (var bllAction in result)
                {
                    BllTask task = repository.GetById(bllAction.TaskId);

                    switch ((BllActionEnum)bllAction.ActionId)
                    {
                    case BllActionEnum.Add:
                        AddWork(new AddTask(task, repository, bllAction.Id, actionRepository), task.UserId);
                        break;

                    case BllActionEnum.Delete:
                        AddWork(new DeleteTask(task.Id, repository, bllAction.Id, actionRepository), task.UserId);
                        break;

                    case BllActionEnum.Update:
                        AddWork(new UpdateTask(task.Id, repository, bllAction.Id, actionRepository), task.UserId);
                        break;

                    default:
                        throw new InvalidEnumArgumentException();
                    }
                }
            }
        }
コード例 #3
0
        public void Execute()
        {
            BllTask result = repository.GetById(itemId);

            ToDoService.UpdateItem(result);

            actionRepository.Delete(actionId);
        }
コード例 #4
0
 public static ORM.Task GetOrmEntity(this BllTask bllEntity)
 {
     return(new ORM.Task
     {
         Id = bllEntity.Id,
         ToDoId = bllEntity.ToDoId,
         UserId = bllEntity.UserId,
         IsCompleted = bllEntity.IsCompleted,
         Name = bllEntity.Name,
         IsDeleted = bllEntity.IsDeleted
     });
 }
コード例 #5
0
        public void Execute()
        {
            ToDoService.CreateItem(item);
            IList <BllTask> result = ToDoService.GetItems(item.UserId);

            BllTask task = repository.GetById(item.Id);

            task.ToDoId = result.LastOrDefault()?.ToDoId;

            repository.Update(task);
            actionRepository.Delete(actionId);
        }
コード例 #6
0
 public static TaskViewModel GetTaskViewEntity(this BllTask bllEntity)
 {
     return(new TaskViewModel()
     {
         Id = bllEntity.Id,
         ToDoId = bllEntity.ToDoId,
         UserId = bllEntity.UserId,
         IsCompleted = bllEntity.IsCompleted,
         Name = bllEntity.Name,
         IsDeleted = bllEntity.IsDeleted
     });
 }
コード例 #7
0
        public BllTask Create(BllTask e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            var result = context.Set <Task>().Add(e.GetOrmEntity());

            context.SaveChanges();

            return(result.GetBllEntity());
        }
コード例 #8
0
        public AddTask(BllTask item, ITaskRepository repository, int actionId, IActionRepository actionRepository)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (repository == null)
            {
                throw new ArgumentNullException(nameof(repository));
            }
            if (actionRepository == null)
            {
                throw new ArgumentNullException(nameof(actionRepository));
            }

            this.item             = item;
            this.repository       = repository;
            this.actionId         = actionId;
            this.actionRepository = actionRepository;
        }
コード例 #9
0
 /// <summary>
 /// Updates a todo.
 /// </summary>
 /// <param name="item">The todo to update.</param>
 public static void UpdateItem(BllTask item)
 {
     httpClient.PutAsJsonAsync(serviceApiUrl + UpdateUrl, item)
     .Result.EnsureSuccessStatusCode();
 }