/// <summary> /// The Delete. /// </summary> /// <param name="paperHashes">The paperHashes<see cref="Models.PaperHashes"/>.</param> /// <returns>The <see cref="Task"/>.</returns> public async Task Delete(Models.PaperHashes paperHashes) { var check = await Read(paperHashes); if (check != null) { _db.PaperHashes.Remove(check); await _db.SaveChangesAsync(); } }
/// <summary> /// The Update. /// </summary> /// <param name="paperHashes">The paperHashes<see cref="Models.PaperHashes"/>.</param> /// <returns>The <see cref="Task{Models.PaperHashes}"/>.</returns> public async Task <Models.PaperHashes> Update(Models.PaperHashes paperHashes) { var check = await Read(paperHashes); if (check != null) { _db.PaperHashes.Update(paperHashes); await _db.SaveChangesAsync(); return(paperHashes); } return(paperHashes); }
/// <summary> /// The Create. /// </summary> /// <param name="paperHashes">The paperHashes<see cref="Models.PaperHashes"/>.</param> /// <returns>The <see cref="Task{Models.PaperHashes}"/>.</returns> public async Task <Models.PaperHashes> Create(Models.PaperHashes paperHashes) { var check = await Read(paperHashes); if (check == null) { await _db.PaperHashes.AddAsync(paperHashes); await _db.SaveChangesAsync(); return(paperHashes); } return(paperHashes); }
/// <summary> /// The Read. /// </summary> /// <param name="paperHashes">The paperHashes<see cref="Models.PaperHashes"/>.</param> /// <returns>The <see cref="Task{Models.PaperHashes}"/>.</returns> public async Task <Models.PaperHashes> Read(Models.PaperHashes paperHashes) { return(await _db.PaperHashes.FirstOrDefaultAsync(x => x.PaperId == paperHashes.PaperId && x.HashTagId == paperHashes.HashTagId)); }