private void CapturePropertyListingFeatures(PropertyListingFeatureView model, int PropetyListingId, FormCollection collection) { try { using (JazMax.DataAccess.JazMaxDBProdContext db = new JazMax.DataAccess.JazMaxDBProdContext()) { string[] ids = collection["PropertyListingFeatureView.PropertyFeatureId"].Split(new char[] { ',' }); foreach (var item in ids) { DataAccess.ProprtyListingFeature table = new DataAccess.ProprtyListingFeature() { IsFeatureActive = true, PropertyListingId = PropetyListingId, PropertyFeatureId = int.Parse(item), }; db.ProprtyListingFeatures.Add(table); db.SaveChanges(); } } } catch (Exception e) { JazMax.BusinessLogic.AuditLog.ErrorLog.LogError(e, 0); } }
public void UpdatePropertyFeatures(PropertyListingFeatureView model, int PropertyListingId) { try { using (JazMax.DataAccess.JazMaxDBProdContext db = new JazMax.DataAccess.JazMaxDBProdContext()) { var features = db.ProprtyListingFeatures.FirstOrDefault(x => x.PropertyFeatureId == model.PropertyFeatureId); features.IsFeatureActive = model.IsFeatureActive; features.PropertyListingId = PropertyListingId; features.PropertyFeatureId = model.PropertyFeatureId; db.SaveChanges(); } } catch (Exception e) { JazMax.BusinessLogic.AuditLog.ErrorLog.LogError(e, 0); } }
//private static JazMax.DataAccess.JazMaxDBProdContext db = new JazMax.DataAccess.JazMaxDBProdContext(); #region GetLists public IQueryable <NewListingView> GetPrimaryListing() { using (JazMax.DataAccess.JazMaxDBProdContext db = new DataAccess.JazMaxDBProdContext()) { List <NewListingView> view = new List <NewListingView>(); #region Joins Query var query = (from a in db.PropertyListings join b in db.PropertyListingAgents on a.PropertyListingId equals b.PropertyListingId join c in db.PropertyListingDetails on a.PropertyListingId equals c.PropertyListingId join d in db.ProprtyListingYoutubeLibraries on a.PropertyListingId equals d.PrfoprtyListingId join e in db.ProprtyListingFeatures on a.PropertyListingId equals e.PropertyListingId select new { a.PropertyListingId, a.BranchId, a.FriendlyName, a.ProprtyDesciption, a.IsListingActive, a.PropertyListingPricingTypeId, a.Price, a.PropertyTypeId, a.LastUpdate, a.ListingDate, a.ProvinceId, b.AgentId, b.IsActive, c.RatesAndTaxes, c.NumberOfBathRooms, c.NumberOfBedrooms, c.NumberOfGarages, c.NumberOfSquareMeters, d.YoutubeVideoLink, e.PropertyFeatureId, }).ToList().AsQueryable(); #endregion foreach (var item in query) { #region Property Listing View PropertyListingView list = new PropertyListingView() { PropertyListingId = item.PropertyListingId, BranchId = item.BranchId, FriendlyName = item.FriendlyName, IsListingActive = item.IsListingActive, PropertyListingPricingTypeId = item.PropertyListingPricingTypeId, Price = item.Price, PropertyTypeId = item.PropertyTypeId, LastUpdate = item.LastUpdate, ListingDate = item.ListingDate, ProvinceId = item.ProvinceId, ProprtyDesciption = item.ProprtyDesciption }; #endregion #region Agent View PropertyListingAgentsView agent = new PropertyListingAgentsView() { AgentId = item.AgentId, IsActive = item.IsActive, }; #endregion #region Details View PropertyListingDetailView details = new PropertyListingDetailView() { RatesAndTaxes = item.RatesAndTaxes, NumberOfBathRooms = item.NumberOfBathRooms, NumberOfBedrooms = item.NumberOfBedrooms, NumberOfGarages = item.NumberOfGarages, NumberOfSquareMeters = item.NumberOfSquareMeters, }; #endregion #region Youtube View PropertyListingYoutubeView youtube = new PropertyListingYoutubeView() { YoutubeVideoLink = item.YoutubeVideoLink, }; #endregion #region Features View PropertyListingFeatureView feature = new PropertyListingFeatureView() { PropertyFeatureId = item.PropertyFeatureId, }; #endregion #region NewList NewListingView lists = new NewListingView() { PropertyListingView = list, PropertyListingAgentsView = agent, PropertyListingDetailView = details, PropertyListingYoutubeView = youtube, PropertyListingFeatureView = feature, }; #endregion view.Add(lists); } return(view.AsQueryable()); } }