public HttpResponseMessage Create(HttpRequestMessage request, XN_KetQuaViewModel ketQuaVm) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { var ketQua = new XN_KetQua(); ketQua.UpdateXN_KetQua(ketQuaVm); this.xN_KetQuaService.AddUpd(ketQua); foreach (var chitietVm in ketQuaVm.lstKetQuaChiTiet) { var ketQuaChiTiet = new XN_KetQua_ChiTiet(); ketQuaChiTiet.UpdateXN_KetQuaChiTiet(chitietVm); this.xN_KetQuaChiTietService.AddUpd(ketQuaChiTiet); } this.xN_KetQuaService.Save(); response = request.CreateResponse(HttpStatusCode.Created); } return response; })); }
public static void UpdateXN_KetQua(this XN_KetQua xnKetQua, XN_KetQuaViewModel xnKetQuaVm) { xnKetQua.RowIDKetQua = xnKetQuaVm.RowIDKetQua; xnKetQua.NgayTraKQ = xnKetQuaVm.NgayTraKQ; xnKetQua.UserTraKQ = xnKetQuaVm.UserTraKQ; xnKetQua.NgayLamXetNghiem = xnKetQuaVm.NgayLamXetNghiem; xnKetQua.MaPhieu = xnKetQuaVm.MaPhieu; xnKetQua.MaChiDinh = xnKetQuaVm.MaChiDinh; xnKetQua.MaDonVi = xnKetQuaVm.MaDonVi; xnKetQua.MaKetQua = xnKetQuaVm.MaKetQua; xnKetQua.MaXetNghiem = xnKetQuaVm.MaXetNghiem; xnKetQua.MaTiepNhan = xnKetQuaVm.MaTiepNhan; xnKetQua.isCoKQ = xnKetQuaVm.isCoKQ; xnKetQua.NgayChiDinh = xnKetQuaVm.NgayChiDinh; xnKetQua.NgayTiepNhan = xnKetQuaVm.NgayTiepNhan; xnKetQua.GhiChu = xnKetQuaVm.GhiChu; xnKetQua.isDongBo = xnKetQuaVm.isDongBo; xnKetQua.isXoa = xnKetQuaVm.isXoa; xnKetQua.MaGoiXN = xnKetQuaVm.MaGoiXN; xnKetQua.IDNhanVienXoa = xnKetQuaVm.IDNhanVienXoa; xnKetQua.NgayGioXoa = xnKetQuaVm.NgayGioXoa; xnKetQua.LyDoXoa = xnKetQuaVm.LyDoXoa; xnKetQua.MaDVCS = xnKetQuaVm.MaDVCS; xnKetQua.MaTrungTam = xnKetQuaVm.MaTrungTam; }
public void AddUpd(XN_KetQua xnKetQua) { var model = this.xN_KetQuaRepository.GetMulti(x => x.MaKetQua == xnKetQua.MaKetQua).FirstOrDefault(); if (model != null) { this.xN_KetQuaRepository.Update(model); } else { this.xN_KetQuaRepository.Add(model); } }