public async Task <CaThi> UpdateCaThi(CaThi caThi) { _context.CaThiContext.Update(caThi); await _context.SaveChangesAsync(); return(caThi); }
public async Task <CaThi> CreateCaThi(CaThi caThi) { await _context.CaThiContext.AddAsync(caThi); await _context.SaveChangesAsync(); return(caThi); }
public ThamGiaCaThiResponse(CaThi caThi, ThiSinh thiSinh) { Id = caThi.Id; TenCaThi = caThi.TenCaThi; ThoiGianBatDau = caThi.ThoiGianBatDau; ThoiGianThi = caThi.ThoiGianThi; TrangThai = caThi.TrangThai; TrangThaiThi = thiSinh.TrangThaiThi; }
public CaThiResponse(CaThi caThi, LopHoc lopHoc, DeThiResponse deThi, TaiKhoan giamThi) { Id = caThi.Id; IdHocPhan = caThi.IdHocPhan; TenCaThi = caThi.TenCaThi; ThoiGianBatDau = caThi.ThoiGianBatDau; ThoiGianThi = caThi.ThoiGianThi; TrangThai = caThi.TrangThai; MaBaoVe = caThi.MaBaoVe; LopHoc = lopHoc; DeThi = deThi; if (giamThi != null) { GiamThi = new ThongTinTaiKhoan(giamThi); } }
public async Task <Response <CaThiResponse> > TaoCaThi(long idHocPhan, TaoCaThiRequest request) { var hocPhan = await _hocPhanRepo.GetHocPhanById(idHocPhan); if (hocPhan == null) { return new Response <CaThiResponse> { StatusCode = 400, Success = false, Errors = new[] { "Không tìm thấy học phần" } } } ; var caThi = new CaThi { TenCaThi = request.TenCaThi, ThoiGianBatDau = request.ThoiGianBatDau, ThoiGianThi = request.ThoiGianThi, TrangThai = TrangThaiCaThi.ChuaBatDau, IdHocPhan = idHocPhan, IdLopHoc = request.IdLopHoc, IdGiamThi = request.IdGiamThi, IdDeThi = request.IdDeThi }; var newCaThi = await _caThiRepo.CreateCaThi(caThi); var lopHoc = await _lopHocRepo.GetLopHocById(newCaThi.IdLopHoc); var deThi = await _deThiRepo.GetDeThiById(newCaThi.IdDeThi); var dsIdCauHoi = _deThiRepo.GetDsIdCauHoi(deThi.Id); var dsCauHoi = await _cauHoiRepo.GetMultipleCauHoiById(dsIdCauHoi); var deThiResponse = new DeThiResponse(deThi, dsCauHoi); var giamThi = await _taiKhoanRepo.GetTaiKhoanById(newCaThi.IdGiamThi); var caThiResponse = new CaThiResponse(newCaThi, lopHoc, deThiResponse, giamThi); var dsSinhVien = _sinhVienRepo.GetAllInLopHoc(lopHoc.Id); foreach (var sinhVien in dsSinhVien) { var thiSinh = new ThiSinh { IdCaThi = newCaThi.Id, IdSinhVien = sinhVien.Id, SoLanDangNhap = 0, TenMay = null, DiaChiIp = null, TrangThaiThi = TrangThaiThi.ChuaThi }; await _thiSinhRepo.CreateThiSinh(thiSinh); } return(new Response <CaThiResponse> { StatusCode = 201, Success = true, Data = caThiResponse }); } }
public async Task DeleteCaThi(CaThi caThi) { _context.CaThiContext.Remove(caThi); await _context.SaveChangesAsync(); }
public void Post(CaThi cathi) { cathi.CaThiId = Guid.NewGuid(); db.CaThi.Add(cathi); db.SaveChanges(); }
public KetQuaResponse(SinhVien sinhVien, CaThi caThi, List <KetQuaCauHoi> dsKetQuaCauHoi) { SinhVien = sinhVien; CaThi = caThi; DsKetQuaCauHoi = dsKetQuaCauHoi; }