public StoreItem() { Photos = new List<PhotoItem>(); Store = new Store(); Category = new StoreCategory(); Colors = new List<ColorDisplay>(); Reviews = new List<ItemReview>(); }
public List<StoreCategory> GetStoreCategories(Guid merchantId) { var output = new List<StoreCategory>(); try { var mc = new ManagementContext(); var categories = mc.StoreItemCategories.Where(x => x.Merchant.MerchantId.Equals(merchantId)); foreach (var dbcategory in categories) { var category = new StoreCategory(); category.Name = dbcategory.Name; category.Description = dbcategory.Description; category.StoreItemCategoryId = dbcategory.StoreItemCategoryId; output.Add(category); } } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return output; }
public DisplayStore GetPublicStore(Guid merchantId, int category) { var store = new DisplayStore(); try { var mc = new ManagementContext(); Merchant merchant = null; merchant = mc.Merchants.Include("Locations").Include("Items").Where(x => x.MerchantId == merchantId).FirstOrDefault(); if (merchant == null) return null; store.ShopName = merchant.ShopName; store.MerchantId = merchant.MerchantId; store.InternalReference = merchant.InternalReference; store.PrivateManagerId = merchant.PrivateManagerId; store.AccountStatus = (MerchantAccountStatus)merchant.MerchantAccountStatus; store.AmountOnAccount = merchant.AmountOnAccount; store.AutoAcceptPayment = merchant.AutoAcceptPayment; store.AutoShipWhenPaymentIsReceived = merchant.AutoShipWhenPaymentIsReceived; store.Bank = merchant.Bank; store.BankAccount = merchant.BankAccount; if (merchant.CurrencyRate == null) { store.Currency = "USD"; store.CurrencyCost = 1; } else { store.Currency = merchant.CurrencyRate.CurrencyAbbrName; store.CurrencyCost = merchant.CurrencyRate.CurrencyExchangePerUSD; } store.IsRDNation = merchant.IsRDNation; store.OrderPayedNotificationEmail = merchant.OrderPayedNotificationEmail; store.PayedFeesToRDN = merchant.PayedFeesToRDN; store.RDNFixedFee = merchant.RDNFixedFee; store.RDNPercentageFee = merchant.RDNPercentageFee; store.ShippingNotificationEmail = merchant.ShippingNotificationEmail; store.TaxRate = merchant.TaxRate; store.IsPublished = merchant.IsPublished; store.Description = merchant.Description; store.WelcomeMessage = merchant.WelcomeMessage; store.StripePublishableKey = merchant.StripePublishableKey; store.AcceptPaymentsViaStripe = merchant.AcceptPaymentsViaStripe; store.AcceptPaymentsViaPaypal = merchant.AcceptPaymentsViaPaypal; if (merchant.Locations.FirstOrDefault() != null) store.Location = Location.LocationFactory.DisplayLocation(merchant.Locations.FirstOrDefault()); var items = merchant.Items.Where(x => x.IsPublished == true); try { if (category > 0) items = items.Where(x => x.Category != null).Where(x => x.Category.StoreItemCategoryId == category); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } foreach (var storeItem in items) { var item = DisplayStoreItem(storeItem); if (item != null) { store.StoreItems.Add(item); } } foreach (var storeItem in merchant.Items.GroupBy(x => x.Category)) { if (storeItem.Key != null) { var cat = store.StoreCategories.Where(x => x.StoreItemCategoryId == storeItem.Key.StoreItemCategoryId).FirstOrDefault(); if (cat == null && storeItem != null && storeItem.Key != null) { StoreCategory c = new StoreCategory(); c.Name = storeItem.Key.Name; c.StoreItemCategoryId = storeItem.Key.StoreItemCategoryId; store.StoreCategories.Add(c); } } } } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return store; }