public async Task <TaskSm> UpdateTaskAsync(TaskSm task) { var entry = db.Attach(mapper.Map <TaskItem>(task)); entry.State = EntityState.Modified; await db.SaveChangesAsync(); return(mapper.Map <TaskSm>(entry.Entity)); }
public async Task <SubTaskSm> UpdateSubTaskAsync(SubTaskSm task) { if (db.SubTaskItems.Any(item => item.Id == task.Id)) { var entity = db.Attach(mapper.Map <SubTaskItem>(task)); entity.State = EntityState.Modified; await db.SaveChangesAsync(); return(mapper.Map <SubTaskSm>(entity)); } else { throw new ArgumentOutOfRangeException("SubTask does not exist"); } }