public async Task <Response <LopHoc> > CapNhatLopHoc(long id, TaoLopHocRequest request) { var existsLopHoc = await _lopHocRepo.GetLopHocById(id); if (existsLopHoc == null) { return new Response <LopHoc> { StatusCode = 400, Success = false, Errors = new[] { "không tìm thấy lơp học" } } } ; existsLopHoc.TenLop = request.TenLopHoc; var updateLopHoc = await _lopHocRepo.UpdateLopHoc(existsLopHoc); return(new Response <LopHoc> { StatusCode = 200, Success = true, Errors = null, Data = updateLopHoc }); } }
public async Task <IActionResult> CapNhatLopHoc(long id, TaoLopHocRequest request) { var claim = User.Claims.FirstOrDefault(c => c.Type == "id"); if (!User.Identity.IsAuthenticated || claim == null) { return(Unauthorized()); } var serviceResult = await _lopHocService.CapNhatLopHoc(id, request); return(Ok(serviceResult)); }
public async Task <Response <LopHoc> > TaoLopHoc(TaoLopHocRequest request) { var lopHoc = new LopHoc { TenLop = request.TenLopHoc }; var newLopHoc = await _lopHocRepo.CreateLopHoc(lopHoc); return(new Response <LopHoc> { StatusCode = 201, Success = true, Errors = null, Data = newLopHoc }); }