public async Task <IActionResult> PutHinhAnh(int id, HinhAnh hinhAnh) { if (id != hinhAnh.Id) { return(BadRequest()); } _context.Entry(hinhAnh).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HinhAnhExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTaiKhoan(int id, TaiKhoan taiKhoan) { if (id != taiKhoan.Id) { return(BadRequest()); } _context.Entry(taiKhoan).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaiKhoanExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <ThuongHieu> > GetThuongHieu(int id) { //var thuongHieu = _context.ThuongHieux // .Include(th => th.LoaiSps) // .ThenInclude(lSp => lSp.SanPhams) // .ThenInclude(sp => sp.KichCoSps) // .Include(th => th.LoaiSps) // .ThenInclude(lSp => lSp.SanPhams) // .ThenInclude(sp => sp.KichCoSps) // .Where(th => th.Id == id) // .FirstOrDefault(); var thuongHieu = await _context.ThuongHieux.SingleAsync(th => th.Id == id); _context.Entry(thuongHieu) .Collection(lsp => lsp.LoaiSps) .Query() .Include(sp => sp.SanPhams) .ThenInclude(sp => sp.HinhAnhs) .Load(); _context.Entry(thuongHieu) .Collection(lsp => lsp.LoaiSps) .Query() .Include(sp => sp.SanPhams) .ThenInclude(sp => sp.KichCoSps) .Load(); _context.Entry(thuongHieu) .Collection(lsp => lsp.HinhAnhs) .Load(); if (thuongHieu == null) { return(NotFound()); } return(thuongHieu); }