public int CreateFlyerType(FlyerTypeRequest flyerTypeRequest) { var flyerType = new FlyerType { TypeName = flyerTypeRequest.TypeName, InDate = DateTime.Now, InUser = flyerTypeRequest.ActionUserID, LastEditDate = DateTime.Now, LastEditUser = flyerTypeRequest.ActionUserID }; this.flyerTypeRepository.Create(flyerType); return(this.dbContext.SaveChanges()); }
public Order ToOrder() { Order result = null; if (OrderId.HasValue) { result = new Order((Int32)OrderId.Value); } var canCreateOrder = result == null && HttpContext.Current != null && HttpContext.Current.User != null; if (canCreateOrder) { if (FlyerType == FlyerTypes.Seller) { result = Order.CreateSellerOrder(HttpContext.Current.User.Identity.Name); } else if (FlyerType == FlyerTypes.Custom) { result = Order.CreateCustomOrder(HttpContext.Current.User.Identity.Name); } else if (FlyerTypes.Buyer == FlyerTypes.Buyer) { result = Order.CreateBuyerOrder(HttpContext.Current.User.Identity.Name); } if (result != null) { OrderId = result.order_id; Name = result.field5; Layout = result.layout; DeliveryDate = result.delivery_date; } } if (result != null) { var orderReflectionProperties = result.GetType().GetProperties().ToDictionary(k => k.Name, v => v); result.type = FlyerType.ToString().ToLower(); result.market_state = MarketState; if (SelectedPricesList != null && (!String.IsNullOrEmpty(MarketType))) { result.market_county = String.Empty; result.market_association = String.Empty; result.market_msa = String.Empty; var marketTypeProperty = orderReflectionProperties["market_" + MarketType.ToLower()]; if (marketTypeProperty != null) { marketTypeProperty.SetValue(result, SelectedPricesList.Markets, null); } result.tota_price = SelectedPricesList.TotalPrice; } result.headline = result.headline ?? String.Empty; result.theme = result.theme ?? String.Empty; result.layout = Layout ?? String.Empty; result.delivery_date = DeliveryDate ?? result.delivery_date; result.mls_number = MlsNumber ?? String.Empty; result.email_subject = EmailSubject ?? String.Empty; result.title = FlyerTitle ?? String.Empty; result.sub_title = result.sub_title ?? String.Empty; result.prop_address1 = StreetAddress ?? String.Empty; result.prop_address2 = result.prop_address2 ?? String.Empty; result.AptSuiteBldg = AptSuiteBldg ?? String.Empty; result.prop_city = City ?? String.Empty; result.prop_state = State ?? String.Empty; result.prop_zipcode = ZipCode ?? String.Empty; result.OpenHouses = OpenHouses ?? String.Empty; result.prop_desc = Description ?? String.Empty; if (!(String.IsNullOrEmpty(PriceRent))) { if (String.Compare(PriceRent, "price", true) == 0) { result.prop_price = String.Format("PRICE|{0}|{1}|", Price.HasValue ? Price.ToString() : String.Empty, PerArea); } else if (String.Compare(PriceRent, "rent", true) == 0) { result.prop_price = String.Format("RENT|{0}|{1}|{2}", Price.HasValue ? Price.ToString() : String.Empty, PerArea, RentPeriod); } } else { result.prop_price = result.prop_price ?? String.Empty; } result.mls_link = result.mls_link ?? String.Empty; if (FlyerType == FlyerTypes.Custom) { result.virtualtour_link = Link.HasText() ? Link : String.Empty; } result.map_link = MapLink ?? String.Empty; result.markup = Markup ?? String.Empty; result.price_range_min = PriceMin.HasValue ? PriceMin.Value.ToString() : String.Empty; result.price_range_max = PriceMax.HasValue ? PriceMax.Value.ToString() : String.Empty; result.location = Location ?? String.Empty; result.more_info = result.more_info ?? String.Empty; result.buyer_message = result.buyer_message ?? String.Empty; for (var i = 0; i < Photos.Length; i++) { var key = "photo" + (i + 1).ToString(); if (orderReflectionProperties.ContainsKey(key)) { orderReflectionProperties[key].SetValue(result, Photos[i] ?? String.Empty, null); } } result.field1 = Email ?? String.Empty; result.field2 = Phone ?? String.Empty; result.field3 = Ext ?? String.Empty; result.field5 = Name ?? Helper.GetCustomerNameByEmail(result.customer_id); result.Bedrooms = Bedrooms ?? String.Empty; result.FullBaths = Bathrooms ?? String.Empty; result.Parking = Parking ?? String.Empty; result.SqFoots = Sqft ?? String.Empty; result.YearBuilt = YearBuilt ?? String.Empty; result.Floors = Floors ?? String.Empty; result.LotSize = LotSize ?? String.Empty; result.Subdivision = Subdivision ?? String.Empty; result.HOA = Hoa; var steps = GetSteps(); var stepIndex = 0; foreach (var kvp in steps) { if (!kvp.Value) { result.LastPageNo = stepIndex; break; } stepIndex++; } var amenities = GetType().GetProperties().Where(p => p.GetCustomAttributes(typeof(AmenityAttribute), false).Length > 0) .ToDictionary(k => (k.GetCustomAttributes(typeof(DisplayNameAttribute), false)[0] as DisplayNameAttribute).DisplayName, v => v.GetValue(this, null).ToString()); result.PropertyFeatures = String.Join(":", amenities.Keys.ToArray()); result.PropertyFeaturesValues = String.Join(":", amenities.Values.ToArray()); result.OtherPropertyFeatures = result.OtherPropertyFeatures ?? String.Empty; Int32 propertyCategoryId; if (Int32.TryParse(PropertyCategoryId, out propertyCategoryId)) { result.PropertyCategory = propertyCategoryId; } Int32 residentialType; if (Int32.TryParse(ResidentialType, out residentialType)) { result.PropertyType = residentialType; } } return(result); }