public int Create(TodoSubtask entity) { var todoSubtask = Mapper.DynamicMap<TodoSubtask, TodoSubtaskDbModel>(entity); _dbContext.Set<TodoSubtaskDbModel>().Add(todoSubtask); _dbContext.SaveChanges(); return todoSubtask.Id; }
public void Delete(TodoSubtask entity) { var removeSubtask = _dbContext.Set<TodoSubtaskDbModel>().FirstOrDefault(subtask => subtask.Id == entity.Id); if (removeSubtask != null) { _dbContext.Set<TodoSubtaskDbModel>().Remove(removeSubtask); } }
public void Update(TodoSubtask entity) { try { _subtaskRepository.Update(entity); _unitOfWork.Commit(); } catch (Exception e) { Log.LogError(e); } }
public TodoSubtask Create(TodoSubtask entity) { try { var id = _subtaskRepository.Create(entity); _unitOfWork.Commit(); return id != 0 ? _subtaskRepository.GetById(id) : null; } catch (Exception e) { Log.LogError(e); return null; } }
public void Update(TodoSubtask entity) { var existedSubtask = _dbContext.Entry<TodoSubtaskDbModel> ( _dbContext.Set<TodoSubtaskDbModel>().Find(entity.Id) ); if (existedSubtask == null) { return; } existedSubtask.State = EntityState.Modified; existedSubtask.Entity.TodoSubtaskName = entity.TodoSubtaskName; existedSubtask.Entity.TodoTaskRefId = entity.TodoTaskRefId; existedSubtask.Entity.TaskStateRefId = entity.TaskStateRefId; }
public object Post(TodoSubtask todoSubtask) { var createdTodoSubtask = _todoSubtaskService.Create(todoSubtask); return createdTodoSubtask; }