public HttpResponseMessage Create(HttpRequestMessage request, DanhMucDonViCoSoViewModel donviVm) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { if (donviVm.isLocked == null) { donviVm.isLocked = false; } var newDonVi = new DanhMucDonViCoSo(); newDonVi.UpdateDonViCoSo(donviVm); donViCoSoService.Add(newDonVi); donViCoSoService.Save(); var gdv = goidvtheotrungtamService.getAllTheoMaTT(newDonVi.MaDVCS.Substring(0, 3)); var gdvdvcs = Mapper.Map <IEnumerable <DanhMucGoiDichVuTrungTam>, IEnumerable <DanhMucGoiDichVuChung> >(gdv); goidvtheodvcsService.Add(newDonVi.MaDVCS, gdvdvcs.ToList()); goidvtheodvcsService.Save(); var responseData = Mapper.Map <DanhMucDonViCoSo, DanhMucDonViCoSoViewModel>(newDonVi); response = request.CreateResponse(HttpStatusCode.Created, responseData); } return response; })); }
public HttpResponseMessage GetGoiDVTT(HttpRequestMessage request, string maTT) { var goitt = goiDichVuTrungTamService.getAllTheoMaTT(maTT); List <string> ma = new List <string>(); foreach (var a in goitt.ToList()) { ma.Add(a.IDGoiDichVuChung); } return(request.CreateResponse(HttpStatusCode.OK, goiDichVuChungService.GetAll(ma))); }