public HttpResponseMessage PutCADPage([FromBody] CADPage postedData) { HttpResponseMessage response = null; try { CADPage cadPageToUpdate; using (EverestPortalContext readContext = new EverestPortalContext()) { cadPageToUpdate = readContext.CADPages.Where(x => x.cadPageId.Equals(postedData.cadPageId)).FirstOrDefault <CADPage>(); } if (cadPageToUpdate != null) { cadPageToUpdate.cadPageTitle = postedData.cadPageTitle; cadPageToUpdate.cadPageDescription = postedData.cadPageDescription; cadPageToUpdate.cadPagePharmacyFileUrl = postedData.cadPagePharmacyFileUrl; cadPageToUpdate.cadPageHospitalFileUrl = postedData.cadPageHospitalFileUrl; } using (EverestPortalContext updateContext = new EverestPortalContext()) { updateContext.Entry(cadPageToUpdate).State = System.Data.Entity.EntityState.Modified; updateContext.SaveChanges(); } //response = Request.CreateResponse<CADPage>(HttpStatusCode.OK,Request.RequestUri.ToString()); response = Request.CreateResponse <CADPage>(HttpStatusCode.OK, postedData); } catch (Exception ex) { } return(response); }
public HttpResponseMessage AddCADPage([FromBody] CADPage postedData) { HttpResponseMessage response = null; try { CADPage newCADPageEntry = new CADPage(); newCADPageEntry.cadPageTitle = postedData.cadPageTitle; newCADPageEntry.cadPageDescription = postedData.cadPageDescription; newCADPageEntry.cadPagePharmacyFileUrl = postedData.cadPagePharmacyFileUrl; newCADPageEntry.cadPageHospitalFileUrl = postedData.cadPageHospitalFileUrl; using (EverestPortalContext context = new EverestPortalContext()) { context.CADPages.Add(newCADPageEntry); context.SaveChanges(); } response = Request.CreateResponse <CADPage>(HttpStatusCode.Created, newCADPageEntry); } catch (Exception ex) { } return(response); }