コード例 #1
0
        /// <summary>
        /// 获取商户类型
        /// </summary>
        /// <returns></returns>
        public static MerchantType GetMerchantType(int id)
        {
            MerchantType merchantType = new MerchantType();
            var          cmdText      = string.Format("select * from MerchantType where id={0}", id);

            try
            {
                using (var conn = Utility.ObtainConn(Utility._gameDbConn))
                {
                    MySqlDataReader reader = MySqlHelper.ExecuteReader(conn, CommandType.Text, cmdText);
                    if (reader.HasRows)
                    {
                        if (reader.Read())
                        {
                            merchantType.Id     = reader.GetInt32(0);
                            merchantType.Name   = reader["Name"].ToString();
                            merchantType.Count  = (int)reader["Count"];
                            merchantType.TypeId = (MerchantTypes)reader["TypeId"];
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                throw;
            }
            return(merchantType);
        }
コード例 #2
0
        /// <summary>
        /// 获取商户类型列表
        /// </summary>
        /// <returns></returns>
        public static List <MerchantType> GetList()
        {
            var result  = new List <MerchantType>();
            var cmdText = @"select * from MerchantType;";

            try
            {
                using (var conn = Utility.ObtainConn(Utility._gameDbConn))
                {
                    MySqlDataReader reader = MySqlHelper.ExecuteReader(conn, CommandType.Text, cmdText);
                    while (reader.Read())
                    {
                        MerchantType merchantType = new MerchantType();
                        merchantType.Id     = reader.GetInt32(0);
                        merchantType.Name   = reader["Name"].ToString();
                        merchantType.Count  = (int)reader["Count"];
                        merchantType.TypeId = (MerchantTypes)reader["TypeId"];

                        result.Add(merchantType);
                    }
                }
            }
            catch (System.Exception ex)
            {
                throw;
            }
            return(result);
        }
コード例 #3
0
        private void LoadTypes(string directoryName)
        {
            var fileNames = Directory.GetFiles(directoryName);
            var fileName  = fileNames[0];
            var reader    = new StreamReader(File.OpenRead(fileName));

            while (!reader.EndOfStream)
            {
                var    line         = reader.ReadLine();
                var    values       = line.Split(',');
                String merchantName = values[0];

                if (!_merchantDictionary.ContainsKey(merchantName))
                {
                    MerchantType type   = MerchantType.UNCLASSIFIED;
                    String       remark = String.Empty;
                    switch (values.Length)
                    {
                    case 2:
                        if (!String.IsNullOrWhiteSpace(values[1]))
                        {
                            type = (MerchantType)Enum.Parse(typeof(MerchantType), values[1]);
                        }
                        break;

                    case 3:
                        if (!String.IsNullOrWhiteSpace(values[1]))
                        {
                            type = (MerchantType)Enum.Parse(typeof(MerchantType), values[1]);
                        }
                        remark = values[2];
                        break;

                    default:
                        break;
                    }

                    Merchant merchant = new Merchant {
                        Name = merchantName, Type = type, Remark = remark
                    };
                    _merchantDictionary.Add(merchantName, merchant);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// 新增商户类型列表
        /// </summary>
        /// <param name="merchantType"></param>
        /// <returns></returns>
        public static bool AddMerchantType(MerchantType merchantType)
        {
            var cmdText    = @"insert into MerchantType (Count,Name,TypeId) values(?Count,?Name,?TypeId)";
            var parameters = new List <MySqlParameter>();

            parameters.Add(new MySqlParameter("?Count", merchantType.Count));
            parameters.Add(new MySqlParameter("?Name", merchantType.Name));
            parameters.Add(new MySqlParameter("?TypeId", merchantType.TypeId));
            try
            {
                return
                    (MySqlHelper.ExecuteNonQuery(Utility._gameDbConn, CommandType.Text, cmdText, parameters.ToArray()) >
                     0);
            }
            catch (System.Exception ex)
            {
                throw;
            }
        }
コード例 #5
0
        public override IDictionary <string, string> GetParameters()
        {
            var param = base.GetParameters();

            param.Add("activity_tags", ActivityTags?.ToJson());
            param.Add("cat_id", CatId?.ToString());
            param.Add("custom_parameters", CustomParameters);
            param.Add("goods_id_list", GoodsIdList?.ToJson());
            param.Add("is_brand_goods", IsBrandGoods?.ToString());
            param.Add("keyword", Keyword);
            param.Add("list_id", ListId);
            param.Add("merchant_type", MerchantType?.ToString());
            param.Add("merchant_type_list", MerchantTypeList?.ToJson());
            param.Add("opt_id", OptId?.ToString());
            param.Add("page", Page?.ToString());
            param.Add("page_size", PageSize?.ToString());
            param.Add("pid", Pid);
            param.Add("sort_type", SortType?.ToString());
            param.Add("with_coupon", WithCoupon?.ToString());
            param.Add("range_list", RangeList?.ToJson());
            return(param);
        }
コード例 #6
0
        /// <summary>
        /// 新增商户类型
        /// </summary>
        public void AddMerchantType()
        {
            var name   = GetString("name");
            var typeid = GetInt("typeid");

            if (string.IsNullOrEmpty(name) || typeid == 0)
            {
                ReturnErrorMsg("参数有误");
                return;
            }
            var merchantType = new MerchantType();

            merchantType.TypeId = (MerchantTypes)typeid;
            merchantType.Name   = name;
            if (MerchantTypeHelper.AddMerchantType(merchantType))
            {
                ReturnCorrectMsg("新增成功");
            }
            else
            {
                ReturnErrorMsg("新增失败");
            }
        }
コード例 #7
0
        public string ToXML()
        {
            NumberFormatInfo moneyFormatInfo = new NumberFormatInfo();

            moneyFormatInfo.NumberDecimalSeparator = ".";

            if (CreditCard == null)
            {
                CreditCard = new CreditCard();
            }

            StringBuilder strXML = new StringBuilder();

            strXML.AppendFormat("<{0}>", "VposRequest");
            if (!string.IsNullOrWhiteSpace(MerchantId))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "MerchantId", MerchantId);
            }
            if (!string.IsNullOrWhiteSpace(Password))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "Password", Password);
            }
            if (!string.IsNullOrWhiteSpace(TransactionId))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "TransactionId", TransactionId);
            }
            if (!string.IsNullOrWhiteSpace(TerminalNo))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "TerminalNo", TerminalNo);
            }
            if (TransactionType.HasValue)
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "TransactionType", TransactionType.ToString());
            }
            if (CurrencyAmount.HasValue)
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "CurrencyAmount", CurrencyAmount.Value.ToString(moneyFormatInfo));
            }
            if (SurchargeAmount.HasValue)
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "SurchargeAmount", SurchargeAmount.Value.ToString(moneyFormatInfo));
            }
            if (CurrencyCode.HasValue)
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "CurrencyCode", (int)Enum.Parse(typeof(Currency), CurrencyCode.ToString()));
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.PointAmount))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "PointAmount", CreditCard.PointAmount);
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.PointCode))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "PointCode", CreditCard.PointCode);
            }
            if (CreditCard.NumberOfInstallments.HasValue)
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "NumberOfInstallments", CreditCard.NumberOfInstallments);
            }
            if (CreditCard.BrandName.HasValue)
            {
                strXML.AppendFormat("{0}={1}&", "BrandName", (int)Enum.Parse(typeof(BrandName), CreditCard.BrandName.ToString()));
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.Pan))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "Pan", CreditCard.Pan);
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.Expiry))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "Expiry", CreditCard.Expiry);
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.CVV))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "Cvv", CreditCard.CVV);
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.SecurityCode))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "SecurityCode", CreditCard.SecurityCode);
            }
            if (!string.IsNullOrWhiteSpace(ReferenceTransactionId))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "ReferenceTransactionId", ReferenceTransactionId);
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.CardHolderName))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "CardHoldersName", CreditCard.CardHolderName);
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.CardHolderIp))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "ClientIp", CreditCard.CardHolderIp);
            }
            if (!string.IsNullOrWhiteSpace(OrderId))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "OrderId", OrderId);
            }
            if (!string.IsNullOrWhiteSpace(OrderDescription))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "OrderDescription", OrderDescription);
            }
            if (!string.IsNullOrWhiteSpace(RecurringFrequencyType))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "RecurringFrequencyType", RecurringFrequencyType);
            }
            if (RecurringFrequency.HasValue)
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "RecurringFrequency", RecurringFrequency);
            }
            if (IsRecurring.HasValue)
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "IsRecurring", IsRecurring.Value);
            }
            if (!string.IsNullOrWhiteSpace(TriggerDate))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "TriggerDate", TriggerDate);
            }
            if (RecurringInstallmentCount.HasValue)
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "RecurringInstallmentCount", RecurringInstallmentCount);
            }
            if (!string.IsNullOrWhiteSpace(CAVV))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "CAVV", CAVV);
            }
            if (!string.IsNullOrWhiteSpace(ECI))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "ECI", ECI);
            }
            if (CustomItems != null)
            {
                strXML.AppendFormat("<{0}>", "CustomItems");
                for (int i = 0; i < CustomItems.Count; i++)
                {
                    strXML.AppendFormat($"<Item name=\"{CustomItems.ElementAt(0).Key}\" value=\"{CustomItems.ElementAt(0).Value}\"/>");
                }
                strXML.AppendFormat("</{0}>", "CustomItems");
            }

            if (DeviceType.HasValue)
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "DeviceType", (int)Enum.Parse(typeof(DeviceType), DeviceType.ToString()));
            }
            if (TransactionDeviceSource.HasValue)
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "TransactionDeviceSource", (int)Enum.Parse(typeof(TransactionDeviceSource), TransactionDeviceSource.ToString()));
            }
            if (!string.IsNullOrWhiteSpace(Extract))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "Extract", Extract);
            }
            if (!string.IsNullOrWhiteSpace(ExpSign))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "ExpSign", ExpSign);
            }
            if (!string.IsNullOrWhiteSpace(MpiTransactionId))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "MpiTransactionId", MpiTransactionId);
            }
            if (!string.IsNullOrWhiteSpace(Location))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "Location", Location);
            }
            if (MerchantType.HasValue)
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "MerchantType", (int)Enum.Parse(typeof(MerchantType), MerchantType.ToString()));
            }
            if (!string.IsNullOrWhiteSpace(SubMerchantId))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "SubMerchantId", SubMerchantId);
            }
            if (!string.IsNullOrWhiteSpace(ClientIp))
            {
                strXML.AppendFormat("<{0}>{1}</{0}>", "ClientIp", ClientIp);
            }



            strXML.AppendFormat("</{0}>", "VposRequest");

            return(strXML.ToString());
        }
コード例 #8
0
        public static void Initialize(IApplicationDbContext context)
        {
            if (!context.EnsureCreated())
            {
                return; //db was already created or error occurred
            }
            //add merchant types
            var cleanersMerchantType = new MerchantType
            {
                Name        = "Cleaners",
                Description = "Cleaners Services"
            };
            var foodDeliveryMerchantType = new MerchantType
            {
                Name        = "Food Delivery",
                Description = "Food Delivery"
            };

            context.MerchantTypes.Add(cleanersMerchantType);
            context.MerchantTypes.Add(foodDeliveryMerchantType);
            context.SaveChanges();

            var testMerchant1 = new Merchant
            {
                MerchantTypeID   = cleanersMerchantType.ID,
                Name             = "Five Star Cleaners",
                Description      = "We know you are on the go and it is not easy to handle all of your day to day chores without feeling stressed! Errands are a part of life but what if you could free up this time in your routine? We can help! Let us show you our first class dry cleaning and laundry services and you'll see why we are the best laundry service around. We have been in the biz since 1994 and we know our stuff. You can trust the professionals to take care of your laundry services. Try us out today and see for yourself!",
                WebsiteUrl       = "robsmitha.com",
                CallToAction     = "Once you try our services, you will love the newfound free time in your routine - we guarantee it!",
                ShortDescription = "No other laundry service can even come close to impressing you like ours.",
            };
            var testMerchant2 = new Merchant
            {
                MerchantTypeID   = cleanersMerchantType.ID,
                Name             = "Easy Street Cleaners",
                Description      = "We know you are on the go and it is not easy to handle all of your day to day chores without feeling stressed! Errands are a part of life but what if you could free up this time in your routine? We can help! Let us show you our first class dry cleaning and laundry services and you'll see why we are the best laundry service around. We have been in the biz since 1994 and we know our stuff. You can trust the professionals to take care of your laundry services. Try us out today and see for yourself!",
                WebsiteUrl       = "robsmitha.com",
                CallToAction     = "Once you try our services, you will love the newfound free time in your routine - we guarantee it!",
                ShortDescription = "Our services use environment friendly products so you can feel good about your impact.",
            };
            var testMerchant3 = new Merchant
            {
                MerchantTypeID   = cleanersMerchantType.ID,
                Name             = "Lucky Charm Cleaners",
                Description      = "We know you are on the go and it is not easy to handle all of your day to day chores without feeling stressed! Errands are a part of life but what if you could free up this time in your routine? We can help! Let us show you our first class dry cleaning and laundry services and you'll see why we are the best laundry service around. We have been in the biz since 1994 and we know our stuff. You can trust the professionals to take care of your laundry services. Try us out today and see for yourself!",
                WebsiteUrl       = "robsmitha.com",
                CallToAction     = "Once you try our services, you will love the newfound free time in your routine - we guarantee it!",
                ShortDescription = "We'll be your good luck charm!",
            };

            var testMerchant4 = new Merchant
            {
                MerchantTypeID   = cleanersMerchantType.ID,
                Name             = "Unicorn Cleaners",
                Description      = "We know you are on the go and it is not easy to handle all of your day to day chores without feeling stressed! Errands are a part of life but what if you could free up this time in your routine? We can help! Let us show you our first class dry cleaning and laundry services and you'll see why we are the best laundry service around. We have been in the biz since 1994 and we know our stuff. You can trust the professionals to take care of your laundry services. Try us out today and see for yourself!",
                WebsiteUrl       = "robsmitha.com",
                CallToAction     = "Once you try our services, you will love the newfound free time in your routine - we guarantee it!",
                ShortDescription = "A truly amazing cleaners with awesome Google reviews.",
            };

            //add test merchants
            var merchants = new List <Merchant>
            {
                testMerchant1,
                testMerchant2,
                testMerchant3,
                testMerchant4,
            };

            context.Merchants.AddRange(merchants);
            context.SaveChanges();

            var merchantImages = new List <MerchantImage>
            {
                new MerchantImage
                {
                    IsDefault  = true,
                    MerchantID = testMerchant1.ID,
                    ImageUrl   = "https://smitha-cdn.s3.us-east-2.amazonaws.com/Content/images/work1.jpg"
                },
                new MerchantImage
                {
                    IsDefault  = true,
                    MerchantID = testMerchant2.ID,
                    ImageUrl   = "https://smitha-cdn.s3.us-east-2.amazonaws.com/Content/images/work2.jpg"
                },
                new MerchantImage
                {
                    IsDefault  = true,
                    MerchantID = testMerchant3.ID,
                    ImageUrl   = "https://smitha-cdn.s3.us-east-2.amazonaws.com/Content/images/work3.jpg"
                },
                new MerchantImage
                {
                    IsDefault  = true,
                    MerchantID = testMerchant4.ID,
                    ImageUrl   = "https://smitha-cdn.s3.us-east-2.amazonaws.com/Content/images/work4.jpg"
                }
            };

            context.MerchantImages.AddRange(merchantImages);

            //add price type
            var priceTypes = new List <PriceType>
            {
                new PriceType
                {
                    Name        = "Fixed",
                    Description = "Fixed Price"
                },
                new PriceType
                {
                    Name           = "Variable",
                    Description    = "Variable Cost Price",
                    IsVariableCost = true
                }
            };

            context.PriceTypes.AddRange(priceTypes);

            //add item types
            var itemTypes = new List <ItemType>
            {
                new ItemType
                {
                    Name        = "Laundry",
                    Description = "Laundry Services"
                },
                new ItemType
                {
                    Name        = "Suit",
                    Description = "Suit Services"
                },
                new ItemType
                {
                    Name        = "Dress",
                    Description = "Dress Services"
                },
                new ItemType
                {
                    Name        = "Alteration",
                    Description = "Alteration Services"
                },
                new ItemType
                {
                    Name        = "Fee",
                    Description = "Service Fee"
                },
            };

            context.ItemTypes.AddRange(itemTypes);


            //unit types
            var unitTypes = new List <UnitType>
            {
                new UnitType
                {
                    Name        = "Quantity",
                    Description = "Unit is measured in quantities",
                    PerUnit     = "Each"
                }
            };

            context.UnitTypes.AddRange(unitTypes);

            var owner = new Role
            {
                Name        = "Owner",
                Description = "Owner of the associated merchant"
            };
            var onlineSignUp = new Role
            {
                Name        = "Online User",
                Description = "Online Sign up user"
            };
            var roles = new List <Role>
            {
                owner,
                onlineSignUp
            };

            context.Roles.AddRange(roles);

            var orderStatusTypes = new List <OrderStatusType>
            {
                new OrderStatusType
                {
                    Name           = "Open",
                    Description    = "Order needs to be paid for",
                    CanAddPayment  = true,
                    CanAddLineItem = true
                },
                new OrderStatusType
                {
                    Name        = "Paid",
                    Description = "Order has been paid for"
                },
                new OrderStatusType
                {
                    Name          = "Partially Paid",
                    Description   = "Order has been partially paid for",
                    CanAddPayment = true
                },
                new OrderStatusType
                {
                    Name        = "Pending",
                    Description = "Order is pending due to a checkout failure"
                }
            };

            context.OrderStatusTypes.AddRange(orderStatusTypes);


            var paymentStatusTypes = new List <PaymentStatusType>
            {
                new PaymentStatusType
                {
                    Name        = "Pending",
                    Description = "Payment is pending"
                },
                new PaymentStatusType
                {
                    Name        = "Paid",
                    Description = "Payment is paid for"
                },
                new PaymentStatusType
                {
                    Name        = "Failed",
                    Description = "Payment failed"
                }
            };

            context.PaymentStatusTypes.AddRange(paymentStatusTypes);

            var paymentTypes = new List <PaymentType>
            {
                new PaymentType
                {
                    Name        = "Credit Card Manual",
                    Description = "Credit Card Manually Entered"
                },
                new PaymentType
                {
                    Name        = "Cash",
                    Description = "Cash",
                },
                new PaymentType
                {
                    Name        = "Check",
                    Description = "Check",
                },
            };

            context.PaymentTypes.AddRange(paymentTypes);
            context.SaveChanges();

            var laundryType    = itemTypes.Single(t => t.Name == "Laundry");
            var alterationType = itemTypes.Single(t => t.Name == "Alteration");
            var dressType      = itemTypes.Single(t => t.Name == "Dress");
            var suitType       = itemTypes.Single(t => t.Name == "Suit");

            var items = new List <Item>();

            for (int i = 0; i < merchants.Count; i++)
            {
                var m       = merchants[i];
                var laundry = new Item
                {
                    MerchantID       = m.ID,
                    ItemTypeID       = laundryType.ID,
                    Cost             = 0,
                    Price            = 1.99M,
                    PriceTypeID      = priceTypes.First().ID,
                    UnitTypeID       = unitTypes.First().ID,
                    Name             = "Laundry item",
                    Description      = "A single laundry item. Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
                    MaxAllowed       = 25,
                    ShortDescription = "Easy wash and fold."
                };
                items.Add(laundry);


                var alteration = new Item
                {
                    MerchantID       = m.ID,
                    ItemTypeID       = alterationType.ID,
                    Cost             = 0,
                    Price            = 5.99M,
                    PriceTypeID      = priceTypes.First().ID,
                    UnitTypeID       = unitTypes.First().ID,
                    Name             = "Clothing Alteration",
                    Description      = "Alteration services. Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
                    MaxAllowed       = 7,
                    ShortDescription = "Alteration serivces at a great price."
                };
                items.Add(alteration);

                var even = i == 0 || i % 2 == 0;
                if (even)
                {
                    var suit = new Item
                    {
                        MerchantID       = m.ID,
                        ItemTypeID       = suitType.ID,
                        Cost             = 0,
                        Price            = 4.99M,
                        PriceTypeID      = priceTypes.First().ID,
                        UnitTypeID       = unitTypes.First().ID,
                        Name             = "Suit & Jacket Cleaning",
                        Description      = "Suit & Jacket Cleaning services. Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
                        MaxAllowed       = 9,
                        ShortDescription = "Go in there with a nice clean suit."
                    };
                    items.Add(suit);
                }
                else
                {
                    var dress = new Item
                    {
                        MerchantID       = m.ID,
                        ItemTypeID       = dressType.ID,
                        Cost             = 0,
                        Price            = 4.99M,
                        PriceTypeID      = priceTypes.First().ID,
                        UnitTypeID       = unitTypes.First().ID,
                        Name             = "Dress Cleaning",
                        Description      = "Dress cleaning services. Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
                        MaxAllowed       = 9,
                        ShortDescription = "Nothing like a clean dress."
                    };
                    items.Add(dress);
                }
            }

            context.Items.AddRange(items);
            context.SaveChanges();

            foreach (var i in items)
            {
                if (i.ItemTypeID == laundryType.ID)
                {
                    context.ItemImages.Add(new ItemImage
                    {
                        IsDefault = true,
                        ItemID    = i.ID,
                        ImageUrl  = "https://smitha-cdn.s3.us-east-2.amazonaws.com/Content/images/laundry.jpg"
                    });
                }
                else if (i.ItemTypeID == alterationType.ID)
                {
                    context.ItemImages.Add(new ItemImage
                    {
                        IsDefault = true,
                        ItemID    = i.ID,
                        ImageUrl  = "https://smitha-cdn.s3.us-east-2.amazonaws.com/Content/images/alterations.jpg"
                    });
                }
                else if (i.ItemTypeID == dressType.ID)
                {
                    context.ItemImages.Add(new ItemImage
                    {
                        IsDefault = true,
                        ItemID    = i.ID,
                        ImageUrl  = "https://smitha-cdn.s3.us-east-2.amazonaws.com/Content/images/dress.jpg"
                    });
                }
                else if (i.ItemTypeID == suitType.ID)
                {
                    context.ItemImages.Add(new ItemImage
                    {
                        IsDefault = true,
                        ItemID    = i.ID,
                        ImageUrl  = "https://smitha-cdn.s3.us-east-2.amazonaws.com/Content/images/suit.jpg"
                    });
                }
                else
                {
                    //default image
                    context.ItemImages.Add(new ItemImage
                    {
                        IsDefault = true,
                        ItemID    = i.ID,
                        ImageUrl  = "https://smitha-cdn.s3.us-east-2.amazonaws.com/Content/images/shirts.jpg"
                    });
                }
            }

            var confirmedServiceRequestStatusType = new ServiceRequestStatusType
            {
                Name                   = "Confirmed",
                Description            = "We have confirmed your service request with the merchant.",
                IsActiveServiceRequest = true
            };
            var serviceRequestStatusTypes = new List <ServiceRequestStatusType>
            {
                new ServiceRequestStatusType
                {
                    Name        = "Created",
                    Description = "The service request has been created and we are confirming with the merchant."
                },
                confirmedServiceRequestStatusType,
                new ServiceRequestStatusType
                {
                    Name                   = "Picking Up",
                    Description            = "The driver is picking up your items.",
                    IsActiveServiceRequest = true
                },
                new ServiceRequestStatusType
                {
                    Name                   = "Merchant Recieved",
                    Description            = "The merchant has recieved your service request and is making preparations.",
                    IsActiveServiceRequest = true
                },
                new ServiceRequestStatusType
                {
                    Name                   = "Dropping Off",
                    Description            = "The driver is dropping off your items.",
                    IsActiveServiceRequest = true
                },
                new ServiceRequestStatusType
                {
                    Name        = "Customer Recieved",
                    Description = "The driver has dropped off the items and the service request has been completed.",
                    IsCompleteServiceRequest = true
                },
                new ServiceRequestStatusType
                {
                    Name        = "Cancelled",
                    Description = "The service request was cancelled.",
                    IsCompleteServiceRequest = true
                },
            };

            context.ServiceRequestStatusTypes.AddRange(serviceRequestStatusTypes);

            var correspondenceStatusTypes = new List <CorrespondenceStatusType>
            {
                new CorrespondenceStatusType
                {
                    Name        = "Needs Confirmation",
                    Description = "The correspondence needs confirmation."
                },
                new CorrespondenceStatusType
                {
                    Name        = "Confirmed",
                    Description = "The correspondence has been confirmed."
                },
                new CorrespondenceStatusType
                {
                    Name        = "User Completing",
                    Description = "A user is completing the correspondence."
                },
                new CorrespondenceStatusType
                {
                    Name        = "Completed",
                    Description = "A user has completed the correspondence."
                }
            };

            context.CorrespondenceStatusTypes.AddRange(correspondenceStatusTypes);

            var customerPickUp = new CorrespondenceType
            {
                Name               = "Customer Pick up",
                Description        = "Pick up from customer.",
                CustomerConfigures = true
            };
            var customerDropOff = new CorrespondenceType
            {
                Name               = "Customer Drop Off",
                Description        = "Drop off to customer.",
                CustomerConfigures = true
            };
            var merchantPickUp = new CorrespondenceType
            {
                Name               = "Merchant Pick up",
                Description        = "Pick up from merchant.",
                MerchantConfigures = true
            };
            var merchantDropOff = new CorrespondenceType
            {
                Name               = "Merchant Drop Off",
                Description        = "Drop off to merchant.",
                MerchantConfigures = true
            };
            var correspondenceTypes = new[]
            {
                customerPickUp,
                customerDropOff,
                merchantPickUp,
                merchantDropOff
            };

            context.CorrespondenceTypes.AddRange(correspondenceTypes);
            context.SaveChanges();


            var laundryWorkflow = new Workflow
            {
                Name        = "Laundry Service",
                Description = "Laundry Service"
            };
            var foodDeliveryWorkflow = new Workflow
            {
                Name        = "Food Delivery",
                Description = "Food Delivery"
            };

            context.Workflows.Add(laundryWorkflow);
            context.Workflows.Add(foodDeliveryWorkflow);
            context.SaveChanges();

            //laundry workflow
            context.WorkflowSteps.Add(new WorkflowStep
            {
                WorkflowID           = laundryWorkflow.ID,
                Step                 = 1,
                CorrespondenceTypeID = customerPickUp.ID
            });
            context.WorkflowSteps.Add(new WorkflowStep
            {
                WorkflowID           = laundryWorkflow.ID,
                Step                 = 2,
                CorrespondenceTypeID = merchantDropOff.ID
            });
            context.WorkflowSteps.Add(new WorkflowStep
            {
                WorkflowID           = laundryWorkflow.ID,
                Step                 = 3,
                CorrespondenceTypeID = merchantPickUp.ID
            });
            context.WorkflowSteps.Add(new WorkflowStep
            {
                WorkflowID           = laundryWorkflow.ID,
                Step                 = 4,
                CorrespondenceTypeID = customerDropOff.ID
            });

            //food delivery workflow
            context.WorkflowSteps.Add(new WorkflowStep
            {
                WorkflowID           = foodDeliveryWorkflow.ID,
                Step                 = 1,
                CorrespondenceTypeID = merchantPickUp.ID
            });
            context.WorkflowSteps.Add(new WorkflowStep
            {
                WorkflowID           = foodDeliveryWorkflow.ID,
                Step                 = 2,
                CorrespondenceTypeID = customerDropOff.ID
            });

            foreach (var m in merchants)
            {
                context.MerchantWorkflows.Add(new MerchantWorkflow
                {
                    WorkflowID = laundryWorkflow.ID,
                    MerchantID = m.ID,
                    IsDefault  = true,
                    DefaultServiceRequestStatusTypeID = confirmedServiceRequestStatusType.ID
                });
                context.MerchantWorkflows.Add(new MerchantWorkflow
                {
                    WorkflowID = foodDeliveryWorkflow.ID,
                    MerchantID = m.ID
                });
            }

            var testMerchant1Locations = new List <MerchantLocation>
            {
                new MerchantLocation
                {
                    City = "Tampa",
                    StateAbbreviation = "FL",
                    Latitude          = 27.950575,
                    Longitude         = -82.457176,
                    MerchantID        = testMerchant1.ID,
                    Phone             = "(123) 456-7890",
                    ContactEmail      = "*****@*****.**",
                    OperatingHours    = "Monday - Friday: 9:00 AM to 5:00 PM",
                },
                new MerchantLocation
                {
                    City = "Tallahassee",
                    StateAbbreviation = "FL",
                    Latitude          = 30.455000,
                    Longitude         = -84.253334,
                    MerchantID        = testMerchant1.ID,
                    Phone             = "(123) 456-7890",
                    ContactEmail      = "*****@*****.**",
                    OperatingHours    = "Monday - Friday: 9:00 AM to 5:00 PM",
                    IsDefault         = true
                },
            };

            var testMerchant2Locations = new List <MerchantLocation>
            {
                new MerchantLocation
                {
                    City = "Tallahassee",
                    StateAbbreviation = "FL",
                    Latitude          = 30.455000,
                    Longitude         = -84.253334,
                    MerchantID        = testMerchant2.ID,
                    Phone             = "(123) 456-7890",
                    ContactEmail      = "*****@*****.**",
                    OperatingHours    = "Monday - Friday: 9:00 AM to 5:00 PM",
                    IsDefault         = true
                },
                new MerchantLocation
                {
                    City = "New York",
                    StateAbbreviation = "NY",
                    Latitude          = 40.712776,
                    Longitude         = -74.005974,
                    MerchantID        = testMerchant2.ID,
                    Phone             = "(123) 456-7890",
                    ContactEmail      = "*****@*****.**",
                    OperatingHours    = "Monday - Friday: 9:00 AM to 5:00 PM",
                },
            };
            var merchantLocations = new List <MerchantLocation>
            {
                new MerchantLocation
                {
                    City = "Beverly Hills",
                    StateAbbreviation = "CA",
                    Latitude          = 34.077200,
                    Longitude         = -118.422450,
                    MerchantID        = testMerchant3.ID,
                    Phone             = "(123) 456-7890",
                    ContactEmail      = "*****@*****.**",
                    OperatingHours    = "Monday - Friday: 9:00 AM to 5:00 PM",
                    IsDefault         = true
                },
                new MerchantLocation
                {
                    City = "Redmond",
                    StateAbbreviation = "WA",
                    Latitude          = 47.751076,
                    Longitude         = -120.740135,
                    MerchantID        = testMerchant4.ID,
                    Phone             = "(123) 456-7890",
                    ContactEmail      = "*****@*****.**",
                    OperatingHours    = "Monday - Friday: 9:00 AM to 5:00 PM",
                    IsDefault         = true
                }
            };

            merchantLocations.AddRange(testMerchant1Locations);
            merchantLocations.AddRange(testMerchant2Locations);

            for (int i = 0; i < merchantLocations.Count; i++)
            {
                var m = merchantLocations[i];
                foreach (var ct in correspondenceTypes.Where(c => c.MerchantConfigures))
                {
                    //configuring dropoff/pickup location
                    context.MerchantLocations.Add(new MerchantLocation
                    {
                        Street1           = m.Street1,
                        City              = m.City,
                        StateAbbreviation = m.StateAbbreviation,
                        Zip                  = m.Zip,
                        Latitude             = m.Latitude,
                        Longitude            = m.Longitude,
                        MerchantID           = m.MerchantID,
                        IsDefault            = m.IsDefault,
                        CorrespondenceTypeID = ct.ID,
                        Phone                = m.Phone,
                        ContactEmail         = m.ContactEmail,
                        OperatingHours       = m.OperatingHours,
                    });
                }
            }

            var userStatusTypes = new List <UserStatusType>
            {
                new UserStatusType
                {
                    Name        = "Submitted / Unconfirmed",
                    Description = "The user has signed up and needs to confirm their email."
                },
                new UserStatusType
                {
                    Name        = "Confirmed",
                    Description = "The user has confirmed their email and is ready for consideration."
                },
                new UserStatusType
                {
                    Name        = "Under Consideration",
                    Description = "The user information is being reviewed."
                },
                new UserStatusType
                {
                    Name        = "Approved",
                    Description = "The user is approved to carry out service request correspondences."
                },
                new UserStatusType
                {
                    Name        = "Denied",
                    Description = "The user is not approved to carry out services."
                },
                new UserStatusType
                {
                    Name        = "Terminated",
                    Description = "The user has been terminated."
                }
            };

            context.UserStatusTypes.AddRange(userStatusTypes);
            context.SaveChanges();
        }
コード例 #9
0
        public override string ToString()
        {
            NumberFormatInfo moneyFormatInfo = new NumberFormatInfo();

            moneyFormatInfo.NumberDecimalSeparator = ".";

            if (CreditCard == null)
            {
                CreditCard = new CreditCard();
            }


            var str = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(HostMerchantId))
            {
                str.AppendFormat("{0}={1}&", "HostMerchantId", HostMerchantId);
            }

            if (AmountCode.HasValue)
            {
                str.AppendFormat("{0}={1}&", "AmountCode", (int)Enum.Parse(typeof(Currency), AmountCode.Value.ToString()));
            }

            str.AppendFormat("{0}={1}&", "Amount", Amount.ToString(moneyFormatInfo));

            if (!string.IsNullOrWhiteSpace(MerchantPassword))
            {
                str.AppendFormat("{0}={1}&", "MerchantPassword", MerchantPassword);
            }
            if (!string.IsNullOrWhiteSpace(TransactionId))
            {
                str.AppendFormat("{0}={1}&", "TransactionId", TransactionId);
            }
            if (!string.IsNullOrWhiteSpace(OrderId))
            {
                str.AppendFormat("{0}={1}&", "OrderID", OrderId);
            }
            if (!string.IsNullOrWhiteSpace(OrderDescription))
            {
                str.AppendFormat("{0}={1}&", "OrderDescription", OrderDescription);
            }
            if (CreditCard.NumberOfInstallments.HasValue)
            {
                str.AppendFormat("{0}={1}&", "InstallmentCount", CreditCard.NumberOfInstallments);
            }
            if (TransactionType.HasValue)
            {
                str.AppendFormat("{0}={1}&", "TransactionType", TransactionType.ToString());
            }

            str.AppendFormat("{0}={1}&", "IsSecure", IsSecure.ToString().ToLowerInvariant());

            if (AllowNotEnrolledCard.HasValue)
            {
                str.AppendFormat("{0}={1}&", "AllowNotEnrolledCard", AllowNotEnrolledCard.ToString().ToLowerInvariant());
            }
            if (!string.IsNullOrWhiteSpace(SuccessUrl))
            {
                str.AppendFormat("{0}={1}&", "SuccessUrl", SuccessUrl);
            }
            if (!string.IsNullOrWhiteSpace(FailUrl))
            {
                str.AppendFormat("{0}={1}&", "FailUrl", FailUrl);
            }
            if (CreditCard.BrandName.HasValue)
            {
                str.AppendFormat("{0}={1}&", "BrandNumber", (int)Enum.Parse(typeof(BrandName), CreditCard.BrandName.ToString()));
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.CVV))
            {
                str.AppendFormat("{0}={1}&", "CVV", CreditCard.CVV);
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.Pan))
            {
                str.AppendFormat("{0}={1}&", "PAN", CreditCard.Pan);
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.ExpireMonth))
            {
                str.AppendFormat("{0}={1}&", "ExpireMonth", CreditCard.ExpireMonth);
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.ExpireYear))
            {
                str.AppendFormat("{0}={1}&", "ExpireYear", CreditCard.ExpireYear);
            }
            if (!string.IsNullOrWhiteSpace(RequestLanguage))
            {
                str.AppendFormat("{0}={1}&", "RequestLanguage", RequestLanguage);
            }
            if (MerchantType.HasValue)
            {
                str.AppendFormat("{0}={1}&", "MerchantType", (int)Enum.Parse(typeof(MerchantType), MerchantType.ToString()));
            }
            if (!string.IsNullOrWhiteSpace(HostTerminalId))
            {
                str.AppendFormat("{0}={1}&", "HostTerminalId", HostTerminalId);
            }
            if (!string.IsNullOrWhiteSpace(HostSubMerchantId))
            {
                str.AppendFormat("{0}={1}&", "HostSubMerchantId", HostSubMerchantId);
            }


            return(str.ToString().Remove(str.ToString().Length - 1));
        }
コード例 #10
0
        public static void Initialize(OperationsContext context)
        {
            if (!context.Database.EnsureCreated())
            {
                return; //db was already created or error occurred
            }

            var general = new MerchantType
            {
                Name        = "General Merchant",
                Description = "General Merchant Default Value",
                CreatedAt   = DateTime.UtcNow,
                Active      = true,
            };
            var online = new MerchantType
            {
                Name        = "Online Merchant",
                Description = "Online Merchant",
                CreatedAt   = DateTime.UtcNow,
                Active      = true,
            };
            var merchantTypes = new List <MerchantType>
            {
                general,
                online
            };

            foreach (var merchantType in merchantTypes)
            {
                context.MerchantTypes.Add(merchantType);
                context.SaveChanges();
            }

            var merchants = new List <Merchant>
            {
                new Merchant
                {
                    MerchantName   = "Rob's Merchant",
                    CreatedAt      = DateTime.UtcNow,
                    Active         = true,
                    WebsiteUrl     = string.Empty,
                    MerchantType   = general,
                    MerchantTypeID = general.ID
                },
                new Merchant
                {
                    MerchantName   = "Online Merchant",
                    CreatedAt      = DateTime.UtcNow,
                    Active         = true,
                    WebsiteUrl     = string.Empty,
                    MerchantType   = online,
                    MerchantTypeID = online.ID
                }
            };

            context.Merchants.AddRange(merchants);

            var itemTypes = new List <ItemType>
            {
                new ItemType
                {
                    Name        = "Merchandise",
                    Description = "Merchandise",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new ItemType
                {
                    Name        = "Discount",
                    Description = "Discount",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                }
            };


            foreach (var itemType in itemTypes)
            {
                context.ItemTypes.Add(itemType);
                context.SaveChanges();
            }


            var priceTypes = new List <PriceType>
            {
                new PriceType
                {
                    Name        = "Fixed",
                    Description = "Fixed Price",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new PriceType
                {
                    Name        = "Variable",
                    Description = "Variable Cost Price",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                }
            };

            foreach (var priceType in priceTypes)
            {
                context.PriceTypes.Add(priceType);
                context.SaveChanges();
            }

            var unitTypes = new List <UnitType>
            {
                new UnitType
                {
                    Name        = "Quantity",
                    Description = "Unit is measured in quantities",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                }
            };

            context.UnitTypes.AddRange(unitTypes);
            var owner = new Role
            {
                Name        = "Owner",
                Description = "Owner of the associated merchant",
                CreatedAt   = DateTime.UtcNow,
                Active      = true,
            };
            var onlineSignUp = new Role
            {
                Name        = "Online User",
                Description = "Online Sign up user",
                CreatedAt   = DateTime.UtcNow,
                Active      = true,
            };
            var roles = new List <Role>
            {
                owner,
                onlineSignUp
            };

            context.Roles.AddRange(roles);

            var orderStatusTypes = new List <OrderStatusType>
            {
                new OrderStatusType
                {
                    Name        = "Open",
                    Description = "Order needs to be paid for",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new OrderStatusType
                {
                    Name        = "Paid",
                    Description = "Order has been paid for",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new OrderStatusType
                {
                    Name        = "Partially Paid",
                    Description = "Order has been partially paid for",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                }
            };

            foreach (var orderStatusType in orderStatusTypes)
            {
                context.OrderStatusTypes.Add(orderStatusType);
                context.SaveChanges();
            }


            var paymentStatusTypes = new List <PaymentStatusType>
            {
                new PaymentStatusType
                {
                    Name        = "Pending",
                    Description = "Payment is pending",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new PaymentStatusType
                {
                    Name        = "Paid",
                    Description = "Payment is paid for",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
            };

            foreach (var paymentStatusType in paymentStatusTypes)
            {
                context.PaymentStatusTypes.Add(paymentStatusType);
                context.SaveChanges();
            }

            var paymentTypes = new List <PaymentType>
            {
                new PaymentType
                {
                    Name        = "Credit Card Manual",
                    Description = "Credit Card Manually Entered",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new PaymentType
                {
                    Name        = "Cash",
                    Description = "Cash",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new PaymentType
                {
                    Name        = "Check",
                    Description = "Check",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
            };

            foreach (var paymentType in paymentTypes)
            {
                context.PaymentTypes.Add(paymentType);
                context.SaveChanges();
            }

            var user = new User
            {
                Username   = "******",
                Email      = "*****@*****.**",
                Password   = "******",
                Active     = true,
                CreatedAt  = DateTime.Now,
                FirstName  = "Rob",
                MiddleName = "Wayne",
                LastName   = "Smitha",
            };

            context.Users.Add(user);

            var @namespace = "Domain.Entities";
            var entities   = AppDomain.CurrentDomain.GetAssemblies()
                             .SelectMany(t => t.GetTypes())
                             .Where(t => t.IsClass && t.Namespace == @namespace &&
                                    t.Name != "BaseModel");
            var entityList = new List <string>();


            var permissions = new List <Permission>();

            foreach (var entity in entities)
            {
                var contollerName = entity.Name;
                if (contollerName != "Blog")
                {
                    var lastLetter = contollerName.Substring(contollerName.Length - 1);
                    switch (lastLetter)
                    {
                    case "y":
                        contollerName = $"{entity.Name.TrimEnd('y')}ies";
                        break;

                    case "s":
                        contollerName = $"{entity.Name}es";
                        break;

                    default:
                        contollerName = $"{entity.Name}s";
                        break;
                    }
                }
                var access = new Permission
                {
                    Name        = $"Access{contollerName}",
                    Description = $"Can Access List {contollerName}",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                    Controller  = contollerName,
                    Action      = "Index"
                };
                permissions.Add(access);
                var create = new Permission
                {
                    Name        = $"Create{contollerName}",
                    Description = $"Can Create {contollerName}",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                    Controller  = contollerName,
                    Action      = "Create"
                };
                permissions.Add(create);
                var edit = new Permission
                {
                    Name        = $"Edit{contollerName}",
                    Description = $"Can Edit {contollerName}",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                    Controller  = contollerName,
                    Action      = "Edit"
                };
                permissions.Add(edit);
                var details = new Permission
                {
                    Name        = $"Details{contollerName}",
                    Description = $"Can Access Details {contollerName}",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                    Controller  = contollerName,
                    Action      = "Details"
                };
                permissions.Add(details);
                var delete = new Permission
                {
                    Name        = $"Delete{contollerName}",
                    Description = $"Can Delete {contollerName}",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                    Controller  = contollerName,
                    Action      = "Delete"
                };
                permissions.Add(delete);
            }
            context.Permissions.AddRange(permissions);
            context.SaveChanges();

            var roleId          = roles.First(x => x.Name == "Owner").ID;
            var rolePermissions = new List <RolePermission>();

            foreach (var permission in permissions)
            {
                rolePermissions.Add(new RolePermission
                {
                    PermissionID = permission.ID,
                    RoleID       = roleId,
                    Active       = true,
                    CreatedAt    = DateTime.Now
                });
            }
            context.RolePermissions.AddRange(rolePermissions);
            context.SaveChanges();
            var merchant = merchants.FirstOrDefault();

            if (merchant != null)
            {
                var merchantUser = new MerchantUser
                {
                    UserID     = user.ID,
                    MerchantID = merchant.ID,
                    RoleID     = roleId,
                    Active     = true,
                    CreatedAt  = DateTime.Now
                };
                context.MerchantUsers.Add(merchantUser);
                context.SaveChanges();
            }

            var blogStatusTypes = new List <BlogStatusType>
            {
                new BlogStatusType
                {
                    Name        = "Drafted",
                    Description = "Drafted",
                    Active      = true,
                    CreatedAt   = DateTime.Now
                },
                new BlogStatusType
                {
                    Name        = "Published",
                    Description = "Published",
                    Active      = true,
                    CreatedAt   = DateTime.Now
                }
            };

            context.BlogStatusTypes.AddRange(blogStatusTypes);
            context.SaveChanges();
        }
コード例 #11
0
        public static void Initialize(ICleanersNextDoorContext context)
        {
            if (!context.EnsureCreated())
            {
                return; //db was already created or error occurred
            }
            //add merchant types
            var merchantType = new MerchantType
            {
                Name        = "Cleaner",
                Description = "Cleaner Services",
                Active      = true,
                CreatedAt   = DateTime.Now
            };

            context.MerchantTypes.Add(merchantType);
            context.SaveChanges();

            //add test merchants
            var merchants = new List <Merchant>
            {
                new Merchant
                {
                    MerchantTypeID    = merchantType.ID,
                    Name              = "Five Star Cleaners",
                    Description       = "Founded in 1987 by the Hernandez brothers, our establishment has been serving up rich coffee sourced from artisan farmers in various regions of South and Central America. We are dedicated to travelling the world, finding the best coffee, and bringing back to you here in our cafe.",
                    Street1           = "3481 Melrose Place",
                    City              = "Beverly Hills",
                    StateAbbreviation = "CA",
                    Zip              = "90210",
                    Phone            = "(123) 456-7890",
                    ContactEmail     = "*****@*****.**",
                    OperatingHours   = "Monday - Friday: 9:00 AM to 5:00 PM",
                    WebsiteUrl       = "robsmitha.com",
                    CallToAction     = "Once you try it, our coffee will be a blissful addition to your everyday morning routine - we guarantee it!",
                    ShortDescription = "Every cup of our quality artisan coffee starts with locally sourced, hand picked ingredients.",
                },
                new Merchant
                {
                    MerchantTypeID    = merchantType.ID,
                    Name              = "Second Base Cleaners",
                    Description       = "Founded in 1987 by the Hernandez brothers, our establishment has been serving up rich coffee sourced from artisan farmers in various regions of South and Central America. We are dedicated to travelling the world, finding the best coffee, and bringing back to you here in our cafe.",
                    Street1           = "3481 Melrose Place",
                    City              = "Beverly Hills",
                    StateAbbreviation = "CA",
                    Zip              = "90210",
                    Phone            = "(123) 456-7890",
                    ContactEmail     = "*****@*****.**",
                    OperatingHours   = "Monday - Friday: 9:00 AM to 5:00 PM",
                    WebsiteUrl       = "robsmitha.com",
                    CallToAction     = "Once you try it, our coffee will be a blissful addition to your everyday morning routine - we guarantee it!",
                    ShortDescription = "Every cup of our quality artisan coffee starts with locally sourced, hand picked ingredients.",
                },
                new Merchant
                {
                    MerchantTypeID    = merchantType.ID,
                    Name              = "Third Time's the Charm Cleaners",
                    Description       = "Founded in 1987 by the Hernandez brothers, our establishment has been serving up rich coffee sourced from artisan farmers in various regions of South and Central America. We are dedicated to travelling the world, finding the best coffee, and bringing back to you here in our cafe.",
                    Street1           = "3481 Melrose Place",
                    City              = "Beverly Hills",
                    StateAbbreviation = "CA",
                    Zip              = "90210",
                    Phone            = "(123) 456-7890",
                    ContactEmail     = "*****@*****.**",
                    OperatingHours   = "Monday - Friday: 9:00 AM to 5:00 PM",
                    WebsiteUrl       = "robsmitha.com",
                    CallToAction     = "Once you try it, our coffee will be a blissful addition to your everyday morning routine - we guarantee it!",
                    ShortDescription = "Every cup of our quality artisan coffee starts with locally sourced, hand picked ingredients.",
                },
                new Merchant
                {
                    MerchantTypeID    = merchantType.ID,
                    Name              = "Forty Oz Cleaners",
                    Description       = "Founded in 1987 by the Hernandez brothers, our establishment has been serving up rich coffee sourced from artisan farmers in various regions of South and Central America. We are dedicated to travelling the world, finding the best coffee, and bringing back to you here in our cafe.",
                    Street1           = "3481 Melrose Place",
                    City              = "Beverly Hills",
                    StateAbbreviation = "CA",
                    Zip              = "90210",
                    Phone            = "(123) 456-7890",
                    ContactEmail     = "*****@*****.**",
                    OperatingHours   = "Monday - Friday: 9:00 AM to 5:00 PM",
                    WebsiteUrl       = "robsmitha.com",
                    CallToAction     = "Once you try it, our coffee will be a blissful addition to your everyday morning routine - we guarantee it!",
                    ShortDescription = "Every cup of our quality artisan coffee starts with locally sourced, hand picked ingredients.",
                },
            };

            context.Merchants.AddRange(merchants);
            context.SaveChanges();

            //add price type
            var priceTypes = new List <PriceType>
            {
                new PriceType
                {
                    Name        = "Fixed",
                    Description = "Fixed Price",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new PriceType
                {
                    Name        = "Variable",
                    Description = "Variable Cost Price",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                }
            };

            context.PriceTypes.AddRange(priceTypes);

            //add item types
            var itemTypes = new List <ItemType>
            {
                new ItemType
                {
                    Active      = true,
                    CreatedAt   = DateTime.Now,
                    Name        = "Laundry",
                    Description = "Laundry Services"
                },
                new ItemType
                {
                    Active      = true,
                    CreatedAt   = DateTime.Now,
                    Name        = "Suit",
                    Description = "Suit Services"
                },
                new ItemType
                {
                    Active      = true,
                    CreatedAt   = DateTime.Now,
                    Name        = "Dress",
                    Description = "Dress Services"
                },
                new ItemType
                {
                    Active      = true,
                    CreatedAt   = DateTime.Now,
                    Name        = "Alteration",
                    Description = "Alteration Services"
                },
                new ItemType
                {
                    Active      = true,
                    CreatedAt   = DateTime.Now,
                    Name        = "Fee",
                    Description = "Service Fee"
                },
            };

            context.ItemTypes.AddRange(itemTypes);

            //add card types
            var cardTypes = new List <CardType>
            {
                new CardType
                {
                    Active      = true,
                    CreatedAt   = DateTime.Now,
                    Name        = "Visa",
                    Description = "Visa Card"
                },
                new CardType
                {
                    Active      = true,
                    CreatedAt   = DateTime.Now,
                    Name        = "America Express",
                    Description = "America Express"
                },
            };

            context.CardTypes.AddRange(cardTypes);

            //unit types
            var unitTypes = new List <UnitType>
            {
                new UnitType
                {
                    Name        = "Quantity",
                    Description = "Unit is measured in quantities",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                }
            };

            context.UnitTypes.AddRange(unitTypes);

            var owner = new Role
            {
                Name        = "Owner",
                Description = "Owner of the associated merchant",
                CreatedAt   = DateTime.UtcNow,
                Active      = true,
            };
            var onlineSignUp = new Role
            {
                Name        = "Online User",
                Description = "Online Sign up user",
                CreatedAt   = DateTime.UtcNow,
                Active      = true,
            };
            var roles = new List <Role>
            {
                owner,
                onlineSignUp
            };

            context.Roles.AddRange(roles);

            var orderStatusTypes = new List <OrderStatusType>
            {
                new OrderStatusType
                {
                    Name        = "Open",
                    Description = "Order needs to be paid for",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new OrderStatusType
                {
                    Name        = "Paid",
                    Description = "Order has been paid for",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new OrderStatusType
                {
                    Name        = "Partially Paid",
                    Description = "Order has been partially paid for",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                }
            };

            context.OrderStatusTypes.AddRange(orderStatusTypes);


            var paymentStatusTypes = new List <PaymentStatusType>
            {
                new PaymentStatusType
                {
                    Name        = "Pending",
                    Description = "Payment is pending",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new PaymentStatusType
                {
                    Name        = "Paid",
                    Description = "Payment is paid for",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
            };

            context.PaymentStatusTypes.AddRange(paymentStatusTypes);

            var paymentTypes = new List <PaymentType>
            {
                new PaymentType
                {
                    Name        = "Credit Card Manual",
                    Description = "Credit Card Manually Entered",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new PaymentType
                {
                    Name        = "Cash",
                    Description = "Cash",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
                new PaymentType
                {
                    Name        = "Check",
                    Description = "Check",
                    CreatedAt   = DateTime.UtcNow,
                    Active      = true,
                },
            };

            context.PaymentTypes.AddRange(paymentTypes);

            context.SaveChanges();

            var items = new List <Item>();

            foreach (var merchant in merchants)
            {
                items.Add(new Item
                {
                    ItemTypeID  = itemTypes.Single(t => t.Name == "Laundry").ID,
                    MerchantID  = merchant.ID,
                    Cost        = 0,
                    Price       = 1.99M,
                    PriceTypeID = priceTypes.First().ID,
                    UnitTypeID  = unitTypes.First().ID,
                    Name        = "Laundry item",
                    Description = "A single laundry item. Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
                    MaxAllowed  = 10
                });

                items.Add(new Item
                {
                    ItemTypeID  = itemTypes.Single(t => t.Name == "Alteration").ID,
                    MerchantID  = merchant.ID,
                    Cost        = 0,
                    Price       = 5.99M,
                    PriceTypeID = priceTypes.First().ID,
                    UnitTypeID  = unitTypes.First().ID,
                    Name        = "Clothing Alteration",
                    Description = "Alteration services. Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
                    MaxAllowed  = 7
                });

                items.Add(new Item
                {
                    ItemTypeID  = itemTypes.Single(t => t.Name == "Dress").ID,
                    MerchantID  = merchant.ID,
                    Cost        = 0,
                    Price       = 4.99M,
                    PriceTypeID = priceTypes.First().ID,
                    UnitTypeID  = unitTypes.First().ID,
                    Name        = "Dress Cleaning",
                    Description = "Dress cleaning services. Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
                    MaxAllowed  = 5
                });

                items.Add(new Item
                {
                    ItemTypeID  = itemTypes.Single(t => t.Name == "Suit").ID,
                    MerchantID  = merchant.ID,
                    Cost        = 0,
                    Price       = 4.99M,
                    PriceTypeID = priceTypes.First().ID,
                    UnitTypeID  = unitTypes.First().ID,
                    Name        = "Suit & Jacket Cleaning",
                    Description = "Suit & Jacket Cleaning services. Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
                    MaxAllowed  = 5
                });
            }
            context.Items.AddRange(items);
            context.SaveChanges();
        }
コード例 #12
0
        public override string ToString()
        {
            NumberFormatInfo moneyFormatInfo = new NumberFormatInfo();

            moneyFormatInfo.NumberDecimalSeparator = ".";

            var str = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(MerchantId))
            {
                str.AppendFormat("{0}={1}&", "MerchantId", MerchantId);
            }
            if (!string.IsNullOrWhiteSpace(MerchantPassword))
            {
                str.AppendFormat("{0}={1}&", "MerchantPassword", MerchantPassword);
            }
            if (TransactionType.HasValue)
            {
                str.AppendFormat("{0}={1}&", "TransactionType", TransactionType.ToString());
            }
            if (!string.IsNullOrWhiteSpace(VerifyEnrollmentRequestId))
            {
                str.AppendFormat("{0}={1}&", "VerifyEnrollmentRequestId", VerifyEnrollmentRequestId);
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.Pan))
            {
                str.AppendFormat("{0}={1}&", "Pan", CreditCard.Pan);
            }
            if (!string.IsNullOrWhiteSpace(CreditCard.Expiry))
            {
                str.AppendFormat("{0}={1}&", "ExpiryDate", CreditCard.Expiry);
            }
            if (PurchaseAmmount.HasValue)
            {
                str.AppendFormat("{0}={1}&", "PurchaseAmount", PurchaseAmmount.Value.ToString(moneyFormatInfo));
            }
            if (Currency.HasValue)
            {
                str.AppendFormat("{0}={1}&", "Currency", (int)Enum.Parse(typeof(Currency), Currency.ToString()));
            }
            if (CreditCard.BrandName.HasValue)
            {
                str.AppendFormat("{0}={1}&", "BrandName", (int)Enum.Parse(typeof(BrandName), CreditCard.BrandName.ToString()));
            }
            if (!string.IsNullOrWhiteSpace(SessionInfo))
            {
                str.AppendFormat("{0}={1}&", "SessionInfo", SessionInfo);
            }
            if (!string.IsNullOrWhiteSpace(SuccessUrl))
            {
                str.AppendFormat("{0}={1}&", "SuccessUrl", SuccessUrl);
            }
            if (!string.IsNullOrWhiteSpace(FailureUrl))
            {
                str.AppendFormat("{0}={1}&", "FailUrl", FailureUrl);
            }
            if (CreditCard.NumberOfInstallments.HasValue)
            {
                str.AppendFormat("{0}={1}&", "InstallmentCount", CreditCard.NumberOfInstallments);
            }
            if (!string.IsNullOrWhiteSpace(IsRecurring))
            {
                str.AppendFormat("{0}={1}&", "IsRecurring", IsRecurring);
            }
            if (!string.IsNullOrWhiteSpace(RecurringFrequency))
            {
                str.AppendFormat("{0}={1}&", "RecurringFrequency", RecurringFrequency);
            }
            if (!string.IsNullOrWhiteSpace(RecurringEndDate))
            {
                str.AppendFormat("{0}={1}&", "RecurringEndDate", RecurringEndDate);
            }
            if (MerchantType.HasValue)
            {
                str.AppendFormat("{0}={1}&", "MerchantType", (int)Enum.Parse(typeof(MerchantType), MerchantType.ToString()));
            }
            if (!string.IsNullOrWhiteSpace(SubMerchantId))
            {
                str.AppendFormat("{0}={1}&", "SubMerchantId", SubMerchantId);
            }

            return(str.ToString().Remove(str.ToString().Length - 1));
        }