public async Task <Watch> GetWatchAsync(long id) { var watch = await _dbContext.Watches .FindAsync(id); if (watch == null) { return(null); } await _dbContext.Entry(watch).Reference(x => x.Brand).LoadAsync(); return(watch); }
public async Task <bool> UpdateBrandAsync(Brand brand) { if (brand.Id == default(long)) { throw new InvalidOperationException("Id of existing entity should be provided."); } _dbContext.Entry(brand).State = EntityState.Modified; _dbContext.Entry(brand).Property(x => x.DateCreated).IsModified = false; try { await _dbContext.SaveChangesAsync(); return(true); } catch (DbUpdateConcurrencyException) { return(false); } }