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()); }
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(); } } } }
public void Execute() { BllTask result = repository.GetById(itemId); ToDoService.UpdateItem(result); actionRepository.Delete(actionId); }
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 }); }
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); }
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 }); }
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()); }
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; }
/// <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(); }