public bool RemoveTableInfo(TableInfoDetailModel tableInfoDetailModel) { _connection.ChangeTracker.Clear(); _connection.TableInfos.Remove(Mapper.MapDetailModelToEntity(tableInfoDetailModel)); return(_connection.SaveChanges() is 1); }
public bool AddTableInfo(TableInfoDetailModel tableInfoDetailModel) { _connection.ChangeTracker.Clear(); var entity = Mapper.MapDetailModelToEntity(tableInfoDetailModel); entity.Category = _connection.TableCategories.FirstOrDefault(x => x.ID == tableInfoDetailModel.Category.ID); _connection.TableInfos.Add(entity); return(_connection.SaveChanges() is 1); }
public bool EditTableInfo(TableInfoDetailModel tableInfoDetailModel) { _connection.ChangeTracker.Clear(); var entityTableInfo = _connection.TableInfos.First(x => x.ID == tableInfoDetailModel.ID); var mappedEntityTableInfo = Mapper.MapDetailModelToEntity(tableInfoDetailModel); if (entityTableInfo != mappedEntityTableInfo) { _connection.Entry(entityTableInfo).CurrentValues.SetValues(mappedEntityTableInfo); return(_connection.SaveChanges() is 1); } else { return(false); } }
public TableDetailModel GetOpenedTable(TableInfoDetailModel tableInfo) => GetOpenedTableById(tableInfo.ID);