public HttpResponseMessage UpdateListing([FromBody] Listing postedData) { HttpResponseMessage response = null; try { Listing listingToUpdate; using (EverestPortalContext readContext = new EverestPortalContext()) { listingToUpdate = readContext.Listings.Where(x => x.listingId.Equals(postedData.listingId)).FirstOrDefault <Listing>(); } if (listingToUpdate != null) { listingToUpdate.listingTitle = postedData.listingTitle; listingToUpdate.listingDescription = postedData.listingDescription; listingToUpdate.listingPharmacyFileUrl = postedData.listingPharmacyFileUrl; listingToUpdate.listingHospitalFileUrl = postedData.listingHospitalFileUrl; } using (EverestPortalContext updateContext = new EverestPortalContext()) { updateContext.Entry(listingToUpdate).State = System.Data.Entity.EntityState.Modified; updateContext.SaveChanges(); } //response = Request.CreateResponse<CADPage>(HttpStatusCode.OK,Request.RequestUri.ToString()); response = Request.CreateResponse <Listing>(HttpStatusCode.OK, postedData); } catch (Exception ex) { } return(response); }
public HttpResponseMessage UpdateMonthlyNewProducts([FromBody] MonthlyNewProduct postedData) { HttpResponseMessage response = null; try { MonthlyNewProduct mdpToUpdate; using (EverestPortalContext readContext = new EverestPortalContext()) { mdpToUpdate = readContext.MonthlyNewProducts.Where(x => x.monthlyNewProductId.Equals(postedData.monthlyNewProductId)).FirstOrDefault <MonthlyNewProduct>(); } if (mdpToUpdate != null) { mdpToUpdate.monthlyNewProductTitle = postedData.monthlyNewProductTitle; mdpToUpdate.monthlyNewProductDescription = postedData.monthlyNewProductDescription; } using (EverestPortalContext updateContext = new EverestPortalContext()) { updateContext.Entry(mdpToUpdate).State = System.Data.Entity.EntityState.Modified; updateContext.SaveChanges(); } //response = Request.CreateResponse<CADPage>(HttpStatusCode.OK,Request.RequestUri.ToString()); response = Request.CreateResponse <MonthlyNewProduct>(HttpStatusCode.OK, postedData); } catch (Exception ex) { } return(response); }
public HttpResponseMessage UpdateNewsAlert([FromBody] NewsAlert postedData) { HttpResponseMessage response = null; try { NewsAlert naToBeUpdated; using (EverestPortalContext readContext = new EverestPortalContext()) { naToBeUpdated = readContext.NewsAlerts.Where(x => x.newsAlertId.Equals(postedData.newsAlertId)).FirstOrDefault <NewsAlert>(); } if (naToBeUpdated != null) { naToBeUpdated.newsAlertTitle = postedData.newsAlertTitle; naToBeUpdated.newsAlertDescription = postedData.newsAlertDescription; } using (EverestPortalContext updateContext = new EverestPortalContext()) { updateContext.Entry(naToBeUpdated).State = System.Data.Entity.EntityState.Modified; updateContext.SaveChanges(); } //response = Request.CreateResponse<CADPage>(HttpStatusCode.OK,Request.RequestUri.ToString()); response = Request.CreateResponse <NewsAlert>(HttpStatusCode.OK, postedData); } catch (Exception ex) { } return(response); }
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 UpdatePopularLink([FromBody] PopularLink postedData) { HttpResponseMessage response = null; try { PopularLink popLinkToBeUpdated; string title = string.Empty; using (EverestPortalContext readContext = new EverestPortalContext()) { popLinkToBeUpdated = readContext.PopularLinks.Where(x => x.popularLinkId.Equals(postedData.popularLinkId)).FirstOrDefault <PopularLink>(); title = popLinkToBeUpdated.popularLinkTitle; } if (popLinkToBeUpdated != null) { popLinkToBeUpdated.popularLinkTitle = postedData.popularLinkTitle; popLinkToBeUpdated.popularLinkDescription = postedData.popularLinkDescription; popLinkToBeUpdated.popularLinkDisplayOrder = postedData.popularLinkDisplayOrder; } using (EverestPortalContext updateContext = new EverestPortalContext()) { updateContext.Entry(popLinkToBeUpdated).State = System.Data.Entity.EntityState.Modified; updateContext.SaveChanges(); } if (title != postedData.popularLinkTitle) { string filePath = string.Empty, newFilePath = string.Empty; if (ConfigurationManager.AppSettings["PopularLinks"] != null) { string popularLinksFolder = ConfigurationManager.AppSettings["PopularLinks"].ToString(); filePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath.Replace("API", "Web") + popularLinksFolder; System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(filePath); var file = dirInfo.GetFiles().Where(x => x.Name == title + x.Extension).FirstOrDefault(); if (filePath != null && System.IO.File.Exists(filePath + @"\" + title + file.Extension)) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath + @"\" + title + file.Extension); fileInfo.CopyTo(filePath + @"\" + postedData.popularLinkTitle + file.Extension); fileInfo.Delete(); } } } //response = Request.CreateResponse<CADPage>(HttpStatusCode.OK,Request.RequestUri.ToString()); response = Request.CreateResponse <PopularLink>(HttpStatusCode.OK, postedData); } catch (Exception ex) { } return(response); }
public bool DeleteCustomFilter([FromBody] ReportFilter Filter) { bool blnDeleted = false; if (Filter.FilterID > 0) { using (var db = new EverestPortalContext()) { ReportFilter ReportFilterSelected = db.ReportFilters.Where(m => m.FilterID == Filter.FilterID).SingleOrDefault(); if (ReportFilterSelected != null) { db.Entry(ReportFilterSelected).State = EntityState.Deleted; db.SaveChanges(); blnDeleted = true; } } } return(blnDeleted); }
public bool EditCustomFilter([FromBody] ReportFilter Filter) { bool blnEdit = false; if (Filter != null) { using (var db = new EverestPortalContext()) { ReportFilter ReportFilterUpdate = db.ReportFilters.Where(m => m.FilterID == Filter.FilterID).SingleOrDefault(); if (ReportFilterUpdate != null) { //ReportFilterUpdate.FilterName = Filter.FilterName; //ReportFilterUpdate.FilterDescription = Filter.FilterDescription; ReportFilterUpdate.SelectedFields = Filter.SelectedFields; ReportFilterUpdate.UpdatedBy = Filter.UpdatedBy; db.Entry(ReportFilterUpdate).State = EntityState.Modified; db.SaveChanges(); blnEdit = true; } } } return(blnEdit); }