public async Task <IActionResult> TraLoi(CauTraLoi model) { var ct = await _serviceCT.GetById(model.IdCT); ct.CauTraLoi = model.TraLoi; if (await UpLoadFile(model.File, ct)) { await _serviceCT.Update(ct); return(Ok(new { status = true, mess = MessageResult.UpdateSuccess })); } else { return(Ok(new { status = false, mess = MessageResult.UpLoadFileFail })); } }
public async Task <IActionResult> DatCauHoi(ctXetDuyetDanhGiaViewModel model) { var deTai = await _serviceDeTai.GetById(model.idDeTai); var xetDuyetVaDanhGia = deTai.XetDuyetVaDanhGia.SingleOrDefault(x => x.Status == 1); var checkCT = await _serviceCT.GetEntity(x => x.IdgiangVien == long.Parse(User.Identity.Name) && x.IdxetDuyet == xetDuyetVaDanhGia.Id); if (checkCT != null) // update { checkCT.CauHoi = model.CauHoi; checkCT.NgayTaoCauHoi = DateTime.Now; if (await UpLoadFile(model.File, checkCT)) { if (model.File == null) { checkCT.TenTepCauHoi = ""; checkCT.TepDinhKemCauHoi = ""; } await _serviceCT.Update(checkCT); return(Ok(new { status = true, mess = "Cập nhật câu hỏi thành công" })); } else { return(Ok(new { status = false, mess = MessageResult.UpLoadFileFail })); } } //create new CtxetDuyetVaDanhGia ct = new CtxetDuyetVaDanhGia { CauHoi = model.CauHoi, IdgiangVien = long.Parse(User.Identity.Name), NgayTaoCauHoi = DateTime.Now, IdxetDuyet = DotHienTai.Id, }; var vaitro = _service.GetEntity(x => x.IdhoiDong == xetDuyetVaDanhGia.IdhoiDong && x.IdgiangVien == long.Parse(User.Identity.Name)).Result.VaiTro; ct.VaiTro = vaitro.Value; if (await UpLoadFile(model.File, ct)) { if (model.File == null) { ct.TenTepCauHoi = ""; ct.TepDinhKemCauHoi = ""; } xetDuyetVaDanhGia.CtxetDuyetVaDanhGia.Add(ct); await _serviceDeTai.Update(deTai); return(Ok(new { status = true, mess = "Đặt câu hỏi thành công" })); } else { return(Ok(new { status = false, mess = MessageResult.UpLoadFileFail })); } }