コード例 #1
0
        public ActionResult TotalProduct(PricingModel model)
        {
            double result = 0;

            if (model != null)
            {
                if (model.ListOfProducts != null && model.ListOfProducts.Count > 0)
                {
                    foreach (Product product in model.ListOfProducts)
                    {
                        try
                        {
                            result = result + CalculateTotal(product.ProductName, product.ProductQuantity);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                    model.Total = (int)Math.Round(result);
                }
                else
                {
                    throw new Exception("List of products is null");
                }
            }
            else
            {
                throw new Exception("Model is null");
            }
            return(PartialView("ListOfProducts", model));
        }
コード例 #2
0
ファイル: PricingExtension.cs プロジェクト: nxlap97/CORE
        public static PricingModel ToViewModel(this Pricing entity, IPricingService pricingService, IMDocumentService documentService)
        {
            var img = new MDocument();

            if (!string.IsNullOrWhiteSpace(entity.ImageId))
            {
                img = documentService.GetById(entity.ImageId);
            }

            var modelVm = new PricingModel()
            {
                Id               = entity.Id,
                CreatedBy        = entity.CreatedBy,
                CreatedDate      = entity.CreatedDate,
                Description      = entity.Description,
                ViewCount        = entity.ViewCount,
                ImageId          = entity.ImageId,
                Name             = entity.Name,
                Published        = entity.Published,
                ShortDescription = entity.ShortDescription,
                ImageUrl         = img?.FileUrl
            };

            return(modelVm);
        }
コード例 #3
0
 public void AddItemPriceTest_addItem_itemAddedToDictionary() {
     PricingModel pricingModel = new PricingModel(new string[0]);
     Dictionary<Item, double> existingDictionary = new Dictionary<Item, double>();            
     pricingModel.AddItemPrice(existingDictionary, "Apple,2.50");
     Assert.AreEqual(1, existingDictionary.Count);
     Assert.IsTrue(existingDictionary.ContainsKey(new Item("Apple")));
     Assert.IsTrue(existingDictionary.ContainsValue(2.50));
 }
コード例 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            PricingModel pricingModel = db.Price.Find(id);

            db.Price.Remove(pricingModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public ActionResult Index()
        {
            ViewBag.Locations = dal.GetLocations();
            ViewBag.Sources   = dal.GetSources();
            PricingModel pm = new PricingModel();

            pm.AvailableClasses = GetClasses();
            return(View(pm));
        }
コード例 #6
0
ファイル: PricingExtension.cs プロジェクト: nxlap97/CORE
 //update
 public static Pricing ToEntity(this PricingModel modelVm, Pricing entity)
 {
     entity.Id               = modelVm.Id;
     entity.Description      = modelVm.Description;
     entity.Name             = modelVm.Name;
     entity.Published        = modelVm.Published;
     entity.ShortDescription = modelVm.ShortDescription;
     entity.ImageId          = modelVm.ImageId;
     return(entity);
 }
コード例 #7
0
        public void PricingModelConstructorTest_multipleEntries_oneEntryIsEmptyString_expectedPricingsCreated() {
            string[] pricings = new string[] {
                "Apple,1.50",
                "Bananas,2.75",
                "  "
            };

            PricingModel pricingModel = new PricingModel(pricings);
            Assert.AreEqual(2, pricingModel.GetCountOfPricings);
        }
コード例 #8
0
 public ActionResult Edit([Bind(Include = "id,Service,Price")] PricingModel pricingModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pricingModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pricingModel));
 }
コード例 #9
0
        public void farmerFunc()
        {
            // Timestamp used to mark when the thread begins.
            DateTime startTime = new DateTime();

            startTime = DateTime.Now;

            System.Timers.Timer eventTimer = new System.Timers.Timer();
            eventTimer.Elapsed  += new ElapsedEventHandler(recountChickens);
            eventTimer.Interval  = 50;
            eventTimer.AutoReset = true;
            eventTimer.Start();

            while (priceCutCounter < 10)
            {
                Thread.Sleep(100);

                Console.Out.WriteLine("ChickenFarm has {0} chickens left", numChickens);
                newPrice = PricingModel.reevaluatePrice();
                ChickenFarm.changePrice(newPrice);

                lock (Program.orderBuffer)
                {
                    if (Program.orderBuffer.IsFull())
                    {
                        orderProcessingObject = new OrderProcessing();
                        for (int i = 0; i < Program.NUM_RETAILERS - 1; i++)
                        {
                            String s = Program.orderBuffer.Consume(i);
                            if (s != null)
                            {
                                Order cfOrder = Decoder.decode(s);
                                orderProcessingObject.setOrder(cfOrder);
                                Thread orderProcessingThread = new Thread(new ThreadStart(orderProcessingObject.orderProcessing));
                                orderProcessingThread.Start();
                            }
                        }
                    }
                }
            }

            // Timestamp used to mark when the thread ends.
            DateTime endTime = new DateTime();

            endTime = DateTime.Now;
            // Time span between start time and end time (thread duration)
            TimeSpan span = endTime.Subtract(startTime);

            System.Console.WriteLine("Total Elapsed Time for ChickenFarm Thread: {0} ms", span.TotalMilliseconds);
            System.Console.WriteLine("ChickenFarm DIES! :(");

            // do not wait for OrderProcessing threads to terminate! This is a poor design
            // choice if this software was implemented in real life, but for the sake of
            // finishing the assignment on time, we will not deal with it.
        }
コード例 #10
0
 public ActionResult ResetProducts(PricingModel model)
 {
     if (model != null)
     {
         model.ListOfProducts          = new List <Product>();
         model.Total                   = 0;
         model.Product.ProductName     = null;
         model.Product.ProductQuantity = 0;
     }
     return(View("Index", model));
 }
コード例 #11
0
        public PricingModel GetPricing()
        {
            var pricingModel = new PricingModel
            {
                Plans          = _planRepository.Query().OrderBy(p => p.OrderIndex).ToList(),
                PlanInfoItems  = _planInfoRepository.Query().OrderBy(i => i.OrderIndex).ToList(),
                PlanInfoValues = _planInfoValueRepository.Query().ToList()
            };

            return(pricingModel);
        }
コード例 #12
0
        public ActionResult Create([Bind(Include = "id,Service,Price")] PricingModel pricingModel)
        {
            if (ModelState.IsValid)
            {
                db.Price.Add(pricingModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pricingModel));
        }
コード例 #13
0
        public void TestMethod1()
        {
            PricingModel pm = new PricingModel();

            for (int i = 0; i < 200; i++)
            {
                int expectedPrevPrice = pm.getCurrentPrice();
                int price             = pm.updatePrice();
                Assert.IsTrue(price >= 80 && price <= 300);
                Assert.AreEqual(expectedPrevPrice, pm.getPreviousPrice());
            }
        }
コード例 #14
0
        public void PricingModelConstructorTest_multipleEntries_oneEntryIsDuplicated_expectedPricingsCreated() {
            string[] pricings = new string[] {
                "Apple,1.50",
                "Bananas,2.75",
                "Apple,2.99"
            };

            PricingModel pricingModel = new PricingModel(pricings);
            Assert.AreEqual(2, pricingModel.GetCountOfPricings);
            Assert.IsTrue(pricingModel.HasPricingForItem(new Item("Apple")));
            Assert.IsTrue(pricingModel.HasPricingForItem(new Item("Bananas")));
        }
コード例 #15
0
ファイル: PricingController.cs プロジェクト: nxlap97/CORE
        public IActionResult AddOrUpdate(string id)
        {
            var model = new PricingModel();

            model.Published = true;
            if (!string.IsNullOrWhiteSpace(id))
            {
                var entity = _pricingService.GetById(id);
                model = entity.ToViewModel(_pricingService, _documentService);
            }

            return(View(model));
        }
コード例 #16
0
ファイル: PricingExtension.cs プロジェクト: nxlap97/CORE
        //create
        public static Pricing ToEntity(this PricingModel modelVm)
        {
            var entity = new Pricing()
            {
                Description      = modelVm.Description,
                Name             = modelVm.Name,
                Published        = modelVm.Published,
                ShortDescription = modelVm.ShortDescription,
                ImageId          = modelVm.ImageId,
                ViewCount        = 0
            };

            return(entity);
        }
コード例 #17
0
        // GET: PricingForm/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PricingModel pricingModel = db.Price.Find(id);

            if (pricingModel == null)
            {
                return(HttpNotFound());
            }
            return(View(pricingModel));
        }
コード例 #18
0
        // GET: TechnicalPricing
        public ActionResult Index(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }


            try
            {
                //file info
                var filedetails = _context.Files.FirstOrDefault(f => f.Id == id);

                ViewBag.FileId   = id;
                ViewBag.FileName = filedetails.FileNumber;

                var reflist = _context.ReferanceNumbers
                              .Where(r => r.IsDeleted == false)
                              .Where(f => f.FileId == id)
                              .Where(f => f.Stage == 4).AsEnumerable();

                var itemlist = _context.LineItems.Include("ReferanceNumber").Where(l => reflist.Contains(l.ReferanceNumber)).Where(l => l.IsRemoved == false).AsEnumerable();

                var lineitemsupliers = _context.LineItemSuppliers.Where(l => itemlist.Contains(l.LineItem)).AsEnumerable();

                var suppliermaster = _context.SupplierMasters.Where(s => lineitemsupliers.Any(l => l.SupplierId.Contains(s.SupplierId)))
                                     .Where(s => s.FileId == id).AsEnumerable();

                List <RfqTotal> RfqTotals = new List <RfqTotal>();

                foreach (var item in reflist)
                {
                    RfqTotals.Add(GetRfqTotal(item.Id));
                }

                var pricingModel = new PricingModel {
                    ReferanceNumbers = reflist, LineItems = itemlist, SupplierOffers = suppliermaster, File = filedetails, RfqTotals = RfqTotals
                };

                //list rfq numbers on pricing
                //lineitems
                ViewBag.FileId = id;

                return(View(pricingModel));
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, e.Message));
            }
        }
コード例 #19
0
        public string InitiateDates(PricingModel searchFilters)
        {
            if (ModelState.IsValid)
            {
                DbUpdates.UpdatedRates(searchFilters, User.Identity.Name);

                PricingHelper pr = new PricingHelper(searchFilters,
                                                     allClasses.Where(s => s.LocationId == searchFilters.Location && s.IntervalNum == searchFilters.IntervalNum && searchFilters.Classes.FirstOrDefault().Contains(s.ClassName)).ToArray());

                return(pr.SetDates());
            }
            else
            {
                return("");
            }
        }
コード例 #20
0
        private double currentPrice;                //Local copy of global price

        //Publisher Constructor
        public Publisher(Int32 label)
        {
            currentPrice = 50;
            if (label == 1)
            {
                Program.GV.set_Pub1_Price(currentPrice);
            }
            else
            {
                Program.GV.set_Pub2_Price(currentPrice);
            }
            p       = 0;
            modeler = new PricingModel();
            books   = RESTOCK_AMT;
            decoder = new Decoder();
            name    = label;
        }
        protected async virtual Task <PricingModel> CreatePricingModel(SellableItem sellableItem, string variantId, CommercePipelineExecutionContext context)
        {
            PricingModel pricingModel = null;

            if (string.IsNullOrWhiteSpace(variantId))
            {
                pricingModel = new PricingModel(sellableItem.ListPrice, sellableItem.GetPolicy <PurchaseOptionMoneyPolicy>().SellPrice, sellableItem.GetComponent <MessagesComponent>());
            }
            else
            {
                var variation = sellableItem.GetVariation(variantId);
                if (variation == null)
                {
                    return(await Task.FromResult(pricingModel).ConfigureAwait(false));
                }

                pricingModel = new PricingModel(variation.ListPrice, variation.GetPolicy <PurchaseOptionMoneyPolicy>().SellPrice, variation.GetComponent <MessagesComponent>());
            }

            return(await Task.FromResult(pricingModel).ConfigureAwait(false));
        }
コード例 #22
0
        /// <summary>
        /// Implied hazard rate calculation
        /// </summary>
        /// <remarks>
        /// This method performs the calculation with the
        /// instrument characteristics. It will coincide with
        /// the ISDA calculation if your object has the standard
        ///  characteristics. Notably:
        /// - The calendar should have no bank holidays, just
        ///   weekends.
        /// - The yield curve should be LIBOR piecewise ant
        ///   in fwd rates, with a discount factor of 1 on the
        ///   calculation date, which coincides with the trade
        ///   date.
        /// - Convention should be Following for yield curve and
        ///   contract cashflows.
        /// - The CDS should pay accrued and mature on standard
        ///   IMM dates, settle on trade date +1 and upfront
        ///   settle on trade date +3.
        /// </remarks>
        /// <param name="targetNPV"></param>
        /// <param name="discountCurve"></param>
        /// <param name="dayCounter"></param>
        /// <param name="recoveryRate"></param>
        /// <param name="accuracy"></param>
        /// <returns></returns>
        public double impliedHazardRate(double targetNPV,
                                        Handle <YieldTermStructure> discountCurve,
                                        DayCounter dayCounter,
                                        double recoveryRate = 0.4,
                                        double accuracy     = 1.0e-6,
                                        PricingModel model  = PricingModel.Midpoint)
        {
            SimpleQuote flatRate = new SimpleQuote(0.0);

            Handle <DefaultProbabilityTermStructure> probability = new Handle <DefaultProbabilityTermStructure>(
                new FlatHazardRate(0, new WeekendsOnly(), new Handle <Quote>(flatRate), dayCounter));

            IPricingEngine engine = null;

            switch (model)
            {
            case PricingModel.Midpoint:
                engine = new MidPointCdsEngine(probability, recoveryRate, discountCurve);
                break;

            case PricingModel.ISDA:
                engine = new IsdaCdsEngine(probability, recoveryRate, discountCurve);
                break;

            default:
                Utils.QL_FAIL("unknown CDS pricing model: " + model);
                break;
            }


            setupArguments(engine.getArguments());
            CreditDefaultSwap.Results results = engine.getResults() as CreditDefaultSwap.Results;

            ObjectiveFunction f     = new ObjectiveFunction(targetNPV, flatRate, engine, results);
            double            guess = runningSpread_ / (1 - recoveryRate) * 365.0 / 360.0;
            double            step  = guess * 0.1;

            return(new Brent().solve(f, accuracy, guess, step));
        }
コード例 #23
0
        public string GeneratePrices(PricingModel searchFilters)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    DbUpdates.UpdatedRates(searchFilters, User.Identity.Name);

                    PricingHelper pr = new PricingHelper(searchFilters,
                                                         allClasses.Where(s => s.LocationId == searchFilters.Location && s.IntervalNum == searchFilters.IntervalNum && searchFilters.Classes.FirstOrDefault().Contains(s.ClassName)).ToArray());
                    return(pr.Excecute());
                }
                else
                {
                    return("");
                }
            }
            catch (Exception ex)
            {
                Log.Instance.Error("--- " + ex.Message + "\n " + ex.InnerException + "\n" + ex.StackTrace);
                return("");
            }
        }
コード例 #24
0
        public ActionResult AddProduct(PricingModel model)
        {
            List <Product> result = new List <Product>();

            if (model != null)
            {
                if (model.Product.ProductName == "A" || model.Product.ProductName == "B" || model.Product.ProductName == "C")
                {
                    result.Add(new Product(model.Product.ProductName, model.Product.ProductQuantity));
                    if (model.ListOfProducts != null)
                    {
                        result.AddRange(model.ListOfProducts);
                    }
                    model.ListOfProducts = result;
                }
            }
            else
            {
                throw new Exception("Model is null");
            }

            ModelState.Clear();
            return(PartialView("ListOfProducts", model));
        }
コード例 #25
0
        public ActionResult Pricing()
        {
            PricingModel pricingModel = _planService.GetPricing();

            return(View(pricingModel));
        }
コード例 #26
0
        // GET: ShoppingKart
        public ActionResult Index()
        {
            PricingModel model = new PricingModel();

            return(View("Index", model));
        }
コード例 #27
0
 public void GetPricingForItemTest_itemInLookup_returnsPriceInLookup() {
     string[] pricings = new string[] { "Apple, 1.00" };
     PricingModel pricingModel = new PricingModel(pricings);
     Assert.AreEqual(1.00, pricingModel.GetPricingForItem(new Item("Apple")));
 }
コード例 #28
0
 public void GetPricingForItemTest_itemNotInLookup_returnsZero() {
     string[] pricings = new string[] { "Apple, 1.00" };
     PricingModel pricingModel = new PricingModel(pricings);
     Assert.AreEqual(0, pricingModel.GetPricingForItem(new Item("Bananas")));
 }
コード例 #29
0
 public void PricingModelConstructorTest_noPricings_emptyResultsReturned() {
     PricingModel pricingModel = new PricingModel(new string[0]);            
     Assert.AreEqual(0, pricingModel.GetCountOfPricings);
 }
コード例 #30
0
        public ActionResult BySupplier(int id)
        {
            List <Pricing>  prices;
            List <Material> materials;
            int             supplierID = id;

            using (var um = new UserManager())
            {
                // any user tied to a supplier can only see their supplier rates
                var currentUser = um.ByUsername(User.Identity.Name);
                if (currentUser.SupplierID != null)
                {
                    supplierID = currentUser.SupplierID.GetValueOrDefault();
                }
            }

            using (var mm = new MaterialsManager())
            {
                materials = mm.BySupplier(supplierID).ToList();
            }

            using (var pm = new PricingManager())
            {
                prices = pm.BySupplier(supplierID).ToList();
            }

            // populate the model
            List <PricingModel> model = new List <PricingModel>();

            foreach (var mat in materials)
            {
                var m = new PricingModel();
                if (prices.Any(p => p.MaterialID == mat.ID))
                {
                    var price = prices.FirstOrDefault(p => p.MaterialID == mat.ID);
                    m.ID           = price.ID;
                    m.CompanyID    = price.CompanyID;
                    m.MaterialID   = price.MaterialID;
                    m.SupplierID   = price.SupplierID;
                    m.CreatedOn    = price.CreatedOn;
                    m.CreatedBy    = price.CreatedBy;
                    m.ModifiedBy   = price.ModifiedBy;
                    m.ModifiedOn   = price.ModifiedOn;
                    m.Price        = price.Price;
                    m.MaterialName = mat.Name;
                }
                else
                {
                    m.ID           = 0;
                    m.MaterialID   = mat.ID;
                    m.SupplierID   = supplierID;
                    m.CreatedOn    = DateTime.Now;
                    m.CreatedBy    = User.Identity.Name;
                    m.ModifiedBy   = User.Identity.Name;
                    m.ModifiedOn   = DateTime.Now;
                    m.MaterialName = mat.Name;
                }

                model.Add(m);
            }

            return(View("PricingList", model));
        }
コード例 #31
0
 public void AddItemPriceTest_addDuplicateItem_exceptionExpected() {
     PricingModel pricingModel = new PricingModel(new string[0]);
     Dictionary<Item, double> existingDictionary = new Dictionary<Item, double>();
     existingDictionary.Add(new Item("Apple"), 1.00);
     pricingModel.AddItemPrice(existingDictionary, "Apple,2.50");
 }
コード例 #32
0
 public void GetItemPriceTest_invalidPricingFormat_missingSeperator_exceptionExpected() {
     PricingModel pricingModel = new PricingModel(new string[0]);
     pricingModel.GetItemPrice("Apple 1.00");
 }
コード例 #33
0
 public PricingController(string[] pricings, string[] promotions) {
     pricingModel = new PricingModel(pricings);            
     promotionModel = new PromotionModel(promotions);            
 }
コード例 #34
0
        public List <PricingModel> pricingModelfiller(int id)
        {
            var  result = new List <PricingModel>();
            PDBC db     = new PDBC("PandaMarketCMS", true);

            db.Connect();

            DataTable dt = db.Select("SELECT [id_MPC],[Quantity],[PriceXquantity],[PricePerquantity],[PriceOff],[offTypeValue],[OffType],[id_MainStarTag],[ISDELETE],[id_PQT],[PriceModule],[PriceShow],[describtion]FROM[tlb_Product_MainProductConnector] Where [id_MProduct]=" + id);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var model = new PricingModel()
                {
                    Id           = Convert.ToInt32(dt.Rows[i]["id_MPC"]),
                    MainTagId    = Convert.ToInt32(dt.Rows[i]["id_MainStarTag"]),
                    OffType      = Convert.ToInt32(dt.Rows[i]["OffType"]),
                    OffVal       = long.Parse(dt.Rows[i]["offTypeValue"].ToString()),
                    PerQuantity  = long.Parse(dt.Rows[i]["PricePerquantity"].ToString()),
                    PriceOff     = long.Parse(dt.Rows[i]["PriceOff"].ToString()),
                    PriceModule  = Convert.ToInt32(dt.Rows[i]["PriceModule"]),
                    PriceShow    = Convert.ToInt32(dt.Rows[i]["PriceShow"]),
                    Quantity     = Convert.ToInt32(dt.Rows[i]["Quantity"]),
                    QuantityType = Convert.ToInt32(dt.Rows[i]["id_PQT"])
                };

                if (dt.Rows[i]["ISDELETE"].ToString() == "1")
                {
                    model.IsDeleted = true;
                }
                else
                {
                    model.IsDeleted = false;
                }

                List <string> attr = new List <string>();
                string        s    = "";
                DataTable     dt1  = db.Select("SELECT B.SCOVValueName FROM [tbl_Product_connectorToMPC_SCOV] as A inner join [tbl_Product_SubCategoryOptionValue] as B On A.id_SCOV=B.id_SCOV WHERE A.id_MPC=" + model.Id + " Group By(B.SCOVValueName)");
                if (dt1.Rows.Count > 0)
                {
                    for (int j = 0; j < dt1.Rows.Count; j++)
                    {
                        attr.Add(dt1.Rows[j]["SCOVValueName"].ToString());
                        s += dt1.Rows[j]["SCOVValueName"].ToString() + " , ";
                    }
                }
                else
                {
                    attr.Add("ندارد");
                }

                model.Attributes  = attr;
                model.Description = s;

                List <int> tags = new List <int>();

                DataTable dt2 = db.Select("SELECT [id_TE] FROM [tbl_Product_tagConnector] WHERE id_MPC=" + model.Id);

                if (dt1.Rows.Count > 0)
                {
                    for (int j = 0; j < dt2.Rows.Count; j++)
                    {
                        tags.Add(Convert.ToInt32(dt2.Rows[j]["id_TE"]));
                    }
                }
                else
                {
                    tags.Add(0);
                }
                model.Tags = tags;

                result.Add(model);
            }

            return(result);
        }
コード例 #35
0
 public void GetItemPriceTest_invalidPricingFormat_invalidNumberOfParameters_exceptionExpected() {
     PricingModel pricingModel = new PricingModel(new string[0]);
     pricingModel.GetItemPrice("Apple, 1.00, 2.00");
 }
コード例 #36
0
		public PlayerVendor(Mobile owner, BaseHouse house)
		{
			Owner = owner;
			House = house;
			m_BankAccount = 1000;
			m_HoldGold = 0;
			m_SellItems = new Hashtable();
            m_PricingModel = PricingModel.ModifiedOSI;   // default pricing model

			// default this based on the mobile placing the vendor
			if (this.Owner != null && this.Owner.AccessLevel > AccessLevel.Player)
				this.StaffOwned = true;

			CantWalk = true;

			if (!Core.AOS)
				NameHue = 0x35;

			InitStats(75, 75, 75);
			InitBody();
			InitOutfit();
			UpdateClothes(this);
			m_PayTimer = new PayTimer(this);
			m_PayTimer.Start();
		}
コード例 #37
0
 public void GetItemPriceTest_validPricingFormat_expectedResultsReturned() {
     PricingModel pricingModel = new PricingModel(new string[0]);
     KeyValuePair<Item, double> itemPrice = pricingModel.GetItemPrice("Apple, 1.00");
     Assert.AreEqual(new Item("Apple"), itemPrice.Key);
     Assert.AreEqual(1.00, itemPrice.Value);
 }
コード例 #38
0
        /// <summary>
        /// the method can be called by execute "update-database" with the nuget-console
        /// </summary>
        /// <param name="context">the database context</param>
        protected override void Seed(BrokerContext context)
        {
            context.ServiceClass.SeedEnumValues <ServiceClass, ServiceClassEnum>(@enum => @enum);

            var uMgr      = new UserManager <ApplicationUser, Guid>(new UserStore <ApplicationUser, ApplicationRole, Guid, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>(context));
            var rMgr      = new RoleManager <ApplicationRole, Guid>(new RoleStore <ApplicationRole, Guid, ApplicationUserRole>(context));
            var adminRole = new ApplicationRole
            {
                Name = "Admin"
            };

            context.Roles.AddOrUpdate(x => x.Name, adminRole);
            var userRole = new ApplicationRole
            {
                Name = "User"
            };

            context.Roles.AddOrUpdate(x => x.Name, userRole);
            var adminUser = new ApplicationUser
            {
                UserName     = "******",
                PasswordHash = uMgr.PasswordHasher.HashPassword("cloudBroker01")
            };

            context.Users.AddOrUpdate(x => x.UserName, adminUser);
            var defaultUser = new ApplicationUser
            {
                UserName     = "******",
                PasswordHash = uMgr.PasswordHasher.HashPassword("12345678")
            };

            context.Users.AddOrUpdate(x => x.UserName, defaultUser);

            var createServicesRule = new Rule
            {
                RuleCode  = "create-services",
                RuleTitle = "Services anlegen",
                RuleDesc  = "Dürfen Nutzer der Rollengruppe neue Services in der Datenbank anlegen?"
            };

            context.Rule.AddOrUpdate(x => x.RuleCode, createServicesRule);
            var editServicesRule = new Rule
            {
                RuleCode  = "edit-services",
                RuleTitle = "Services bearbeiten",
                RuleDesc  = "Dürfen Nutzer der Rollengruppe Services in der Datenbank verändern?"
            };

            context.Rule.AddOrUpdate(x => x.RuleCode, editServicesRule);
            var deleteServicesRule = new Rule
            {
                RuleCode  = "delete-services",
                RuleTitle = "Services löschen",
                RuleDesc  = "Dürfen Nutzer der Rollengruppe Services aus der Datenbank löschen?"
            };

            context.Rule.AddOrUpdate(x => x.RuleCode, deleteServicesRule);
            var editSecurityGuidelines = new Rule
            {
                RuleCode  = "edit-security-guidelines",
                RuleTitle = "Rollenberechtigungen bearbeiten",
                RuleDesc  = "Dürfen Nutzer der Rollengruppe Rollenberechtigungen bearbeiten?"
            };

            context.Rule.AddOrUpdate(x => x.RuleCode, editSecurityGuidelines);
            var registerRoles = new Rule
            {
                RuleCode  = "register-roles",
                RuleTitle = "Rollen anlegen",
                RuleDesc  = "Dürfen Nutzer der Rollengruppe Rollen hinzufügen?"
            };

            context.Rule.AddOrUpdate(x => x.RuleCode, registerRoles);
            var deleteRoles = new Rule
            {
                RuleCode  = "delete-roles",
                RuleTitle = "Rollen löschen",
                RuleDesc  = "Dürfen Nutzer der Rollengruppe Rollen entfernen?"
            };

            context.Rule.AddOrUpdate(x => x.RuleCode, deleteRoles);
            var manageUseCases = new Rule
            {
                RuleCode  = "manage-use-cases",
                RuleTitle = "Use-Cases verwalten",
                RuleDesc  = "Dürfen Nutzer der Rollengruppe Use-Cases erstellen, ändern und löschen?"
            };

            context.Rule.AddOrUpdate(x => x.RuleCode, deleteRoles);

            context.SaveChanges();

            context.UseCase.Add(new UseCase
            {
                Creation            = DateTime.Now,
                TitleDE             = "Ich möchte mit meinen Kollegen gemeinsam Dokumente erstellen und bearbeiten",
                TitleEN             = null,
                TitleES             = null,
                InternalDescription = null,
                ServiceClassMapping = context.ServiceClass.Where(x => new List <int> {
                    4
                }.Contains(x.Id)).ToList()
            });
            context.UseCase.Add(new UseCase
            {
                Creation            = DateTime.Now,
                TitleDE             = "Ich möchte meinen Arbeitsplatz mit mehreren Endgeräten synchronisieren",
                TitleEN             = null,
                TitleES             = null,
                InternalDescription = null,
                ServiceClassMapping = context.ServiceClass.Where(x => new List <int> {
                    4
                }.Contains(x.Id)).ToList()
            });
            context.UseCase.Add(new UseCase
            {
                Creation            = DateTime.Now,
                TitleDE             = "Ich möchte Medien (Fotos, Videos etc,) über das Internet streamen",
                TitleEN             = null,
                TitleES             = null,
                InternalDescription = null,
                ServiceClassMapping = context.ServiceClass.Where(x => new List <int> {
                    3
                }.Contains(x.Id)).ToList()
            });
            context.UseCase.Add(new UseCase
            {
                Creation            = DateTime.Now,
                TitleDE             = "Ich möchte Dateien und Ordner mit anderen teilen",
                TitleEN             = null,
                TitleES             = null,
                InternalDescription = null,
                ServiceClassMapping = context.ServiceClass.Where(x => new List <int> {
                    4
                }.Contains(x.Id)).ToList()
            });
            context.UseCase.Add(new UseCase
            {
                Creation            = DateTime.Now,
                TitleDE             = "Ich möchte regelmäßige Backups von meinen Dateien erstellen",
                TitleEN             = null,
                TitleES             = null,
                InternalDescription = null,
                ServiceClassMapping = context.ServiceClass.Where(x => new List <int> {
                    4
                }.Contains(x.Id)).ToList()
            });
            context.UseCase.Add(new UseCase
            {
                Creation            = DateTime.Now,
                TitleDE             = "Ich möchte Dateien für eine Applikation bereitstellen",
                TitleEN             = null,
                TitleES             = null,
                InternalDescription = null,
                ServiceClassMapping = context.ServiceClass.Where(x => new List <int> {
                    0
                }.Contains(x.Id)).ToList()
            });
            context.UseCase.Add(new UseCase
            {
                Creation            = DateTime.Now,
                TitleDE             = "Ich benötige (peristenten) Speicher für einen Container (z.B. Docker)",
                TitleEN             = null,
                TitleES             = null,
                InternalDescription = null,
                ServiceClassMapping = context.ServiceClass.Where(x => new List <int> {
                    0
                }.Contains(x.Id)).ToList()
            });
            context.UseCase.Add(new UseCase
            {
                Creation            = DateTime.Now,
                TitleDE             = "Ich benötige Speicher für den Betrieb eigener Applikationen (z.B. ERP-System)",
                TitleEN             = null,
                TitleES             = null,
                InternalDescription = null,
                ServiceClassMapping = context.ServiceClass.Where(x => new List <int> {
                    0
                }.Contains(x.Id)).ToList()
            });
            context.UseCase.Add(new UseCase
            {
                Creation            = DateTime.Now,
                TitleDE             = "Ich benötige Laufwerke für virtuelle Maschinen",
                TitleEN             = null,
                TitleES             = null,
                InternalDescription = null,
                ServiceClassMapping = context.ServiceClass.Where(x => new List <int> {
                    0
                }.Contains(x.Id)).ToList()
            });
            context.UseCase.Add(new UseCase
            {
                Creation            = DateTime.Now,
                TitleDE             = "Ich benötige lokalen Speicher für Datenbanken",
                TitleEN             = null,
                TitleES             = null,
                InternalDescription = null,
                ServiceClassMapping = context.ServiceClass.Where(x => new List <int> {
                    0
                }.Contains(x.Id)).ToList()
            });
            context.UseCase.Add(new UseCase
            {
                Creation            = DateTime.Now,
                TitleDE             = "Ich benötige Speicher für die Bereitstellung von Bildern und Websiteinhalten",
                TitleEN             = null,
                TitleES             = null,
                InternalDescription = null,
                ServiceClassMapping = context.ServiceClass.Where(x => new List <int> {
                    3
                }.Contains(x.Id)).ToList()
            });

            uMgr.AddToRole <ApplicationUser, Guid>(adminUser.Id, adminRole.Name);
            uMgr.AddToRole <ApplicationUser, Guid>(defaultUser.Id, userRole.Name);

            adminRole.Rules.Add(createServicesRule);
            adminRole.Rules.Add(editServicesRule);
            adminRole.Rules.Add(deleteServicesRule);
            adminRole.Rules.Add(editSecurityGuidelines);
            adminRole.Rules.Add(registerRoles);
            adminRole.Rules.Add(deleteRoles);
            adminRole.Rules.Add(manageUseCases);

            var pricingPeriodD = new PricingPeriod {
                PricingPeriodName = "Täglich", PricingPeriodeCode = "daily"
            };
            var pricingPeriodM = new PricingPeriod {
                PricingPeriodName = "Monatlich", PricingPeriodeCode = "monthly"
            };
            var pricingPeriodA = new PricingPeriod {
                PricingPeriodName = "Jährlich", PricingPeriodeCode = "annually"
            };

            context.PricingPeriod.Add(pricingPeriodD);
            context.PricingPeriod.Add(pricingPeriodM);
            context.PricingPeriod.Add(pricingPeriodA);

            var pricingModelUSR = new PricingModel {
                PricingModelName = "Nutzer-basiert"
            };
            var pricingModelUSA = new PricingModel {
                PricingModelName = "Nutzungs-basiert"
            };
            var pricingModelHYB = new PricingModel {
                PricingModelName = "Hybride Preiskalkulation"
            };

            context.PricingModel.Add(pricingModelUSR);
            context.PricingModel.Add(pricingModelUSA);
            context.PricingModel.Add(pricingModelHYB);

            var deploymentPUB = new DeploymentInfo {
                DeploymentName = "Public"
            };
            var deploymentPRV = new DeploymentInfo {
                DeploymentName = "Private"
            };

            context.DeploymentInfo.Add(deploymentPUB);
            context.DeploymentInfo.Add(deploymentPRV);

            var cert1 = new Certificate {
                CertificateName = "ISO 27001"
            };
            var cert3 = new Certificate {
                CertificateName = "SOC 1"
            };
            var cert4 = new Certificate {
                CertificateName = "SOC 2"
            };
            var cert5 = new Certificate {
                CertificateName = "SOC 3"
            };
            var cert6 = new Certificate {
                CertificateName = "PCI DSS"
            };
            var cert7 = new Certificate {
                CertificateName = "CSA STAR"
            };
            var cert8 = new Certificate {
                CertificateName = "GDPR"
            };
            var cert9 = new Certificate {
                CertificateName = "ISO 27017"
            };
            var cert10 = new Certificate {
                CertificateName = "ISO 27018"
            };

            context.Certificate.Add(cert1);
            context.Certificate.Add(cert3);
            context.Certificate.Add(cert4);
            context.Certificate.Add(cert5);
            context.Certificate.Add(cert6);
            context.Certificate.Add(cert7);
            context.Certificate.Add(cert8);
            context.Certificate.Add(cert9);
            context.Certificate.Add(cert10);

            var locationTypeC = new DataLocationType {
                TypeNameDE = "Kontinent",
                TypeNameEN = "Continent",
                TypeNameES = "Continente"
            };
            var locationTypeR = new DataLocationType {
                TypeNameDE = "Region",
                TypeNameEN = "Region",
                TypeNameES = "Región"
            };
            var locationTypeL = new DataLocationType {
                TypeNameDE = "Land",
                TypeNameEN = "Country",
                TypeNameES = "Pais"
            };

            context.DataLocationType.Add(locationTypeC);
            context.DataLocationType.Add(locationTypeR);
            context.DataLocationType.Add(locationTypeL);

            context.SaveChanges();

            var dataLocationEU = new DataLocation {
                DataLocationNameDE = "EU",
                DataLocationNameEN = "EU",
                DataLocationNameES = "EU",
                DataLocationTypeId = locationTypeC.Id
            };
            var dataLocationGER = new DataLocation {
                DataLocationNameDE = "Deutschsprachiger Raum",
                DataLocationNameEN = "German speaking area",
                DataLocationNameES = "Área de habla alemana",
                DataLocationTypeId = locationTypeR.Id
            };

            context.DataLocation.Add(dataLocationEU);
            context.DataLocation.Add(dataLocationGER);

            CloudServiceModel saaSModel = new CloudServiceModel
            {
                CloudServiceModelName = "Saas"
            };
            CloudServiceModel iaaSModel = new CloudServiceModel
            {
                CloudServiceModelName = "IaaS"
            };
            CloudServiceModel paaSModel = new CloudServiceModel
            {
                CloudServiceModelName = "PaaS"
            };

            context.CloudServiceModel.AddOrUpdate(saaSModel);
            context.CloudServiceModel.AddOrUpdate(iaaSModel);
            context.CloudServiceModel.AddOrUpdate(paaSModel);

            Provider dropboxProvider = new Provider
            {
                ProviderName = "Dropbox",
                URL          = "https://www.dropbox.com/"
            };
            Provider stratoProvider = new Provider
            {
                ProviderName = "Strato",
                URL          = "https://www.strato.de/cloud-speicher/"
            };
            Provider googleProvider = new Provider
            {
                ProviderName = "Google Cloud",
                URL          = "https://cloud.google.com/"
            };
            Provider awsProvider = new Provider
            {
                ProviderName = "Amazon Web Services (AWS)",
                URL          = "https://aws.amazon.com/de/"
            };
            Provider azureProvider = new Provider
            {
                ProviderName = "Microsoft Azure",
                URL          = "https://azure.microsoft.com/de-de/"
            };
            Provider digitalOceanProvider = new Provider
            {
                ProviderName = "DigitalOcean",
                URL          = "https://www.digitalocean.com/"
            };
            Provider hetznerProvider = new Provider
            {
                ProviderName = "Hetzner",
                URL          = "https://www.hetzner.de"
            };
            Provider rackspaceProvider = new Provider
            {
                ProviderName = "Rackspace",
                URL          = "https://www.rackspace.com/"
            };
            Provider ibmProvider = new Provider
            {
                ProviderName = "IBM",
                URL          = "https://www.ibm.com/cloud/"
            };
            Provider ionosProvider = new Provider
            {
                ProviderName = "IONOS",
                URL          = "https://www.ionos.de/enterprise-cloud/object-storage"
            };
            Provider gridscaleProvider = new Provider
            {
                ProviderName = "Gridscale",
                URL          = "https://gridscale.io/"
            };

            context.Provider.AddOrUpdate(dropboxProvider);
            context.Provider.AddOrUpdate(stratoProvider);
            context.Provider.AddOrUpdate(googleProvider);
            context.Provider.AddOrUpdate(awsProvider);
            context.Provider.AddOrUpdate(azureProvider);
            context.Provider.AddOrUpdate(digitalOceanProvider);
            context.Provider.AddOrUpdate(hetznerProvider);
            context.Provider.AddOrUpdate(rackspaceProvider);
            context.Provider.AddOrUpdate(ibmProvider);
            context.Provider.AddOrUpdate(ionosProvider);
            context.Provider.AddOrUpdate(gridscaleProvider);

            Feature hasFileEncryption = new Feature
            {
                Color         = "#1a78b8",
                DescriptionDE = "Dateiverschlüsselung",
                DescriptionEN = "File encryption",
                DescriptionES = "Cifrado de archivos",
                Icon          = "vpn_key"
            };
            Feature hasReplication = new Feature
            {
                Color         = "#1c17bd",
                DescriptionDE = "Redundante Datenspeicherung",
                DescriptionEN = "File replication",
                DescriptionES = "Replicación de archivos",
                Icon          = "file_copy"
            };
            Feature hasVersioning = new Feature
            {
                Color         = "#a74ddb",
                DescriptionDE = "Dateiversionierung",
                DescriptionEN = "File versioning",
                DescriptionES = "Versionado de archivos",
                Icon          = "restore"
            };
            Feature hasPermissions = new Feature
            {
                Color         = "#f00e7b",
                DescriptionDE = "Nutzerberechtigungssystem",
                DescriptionEN = "File permissions",
                DescriptionES = "Permisos de archivos",
                Icon          = "security"
            };
            Feature hasAutomatedSynchronization = new Feature
            {
                Color         = "#3c9e49",
                DescriptionDE = "Automatische Synchronisation",
                DescriptionEN = "Automated synchronization",
                DescriptionES = "sincronización automatizada",
                Icon          = "cached"
            };
            Feature hasLocking = new Feature
            {
                Color         = "#e81046",
                DescriptionDE = "Datei Sperren",
                DescriptionEN = "File locking",
                DescriptionES = "bloqueo de archivos",
                Icon          = "block"
            };

            context.Feature.Add(hasFileEncryption);
            context.Feature.Add(hasReplication);
            context.Feature.Add(hasVersioning);
            context.Feature.Add(hasPermissions);
            context.Feature.Add(hasAutomatedSynchronization);
            context.Feature.Add(hasLocking);
            context.SaveChanges();

            context.OnlineDriveStorageService.AddOrUpdate(
                x => x.ServiceName,
                new OnlineDriveStorageService
            {
                ServiceName          = "Dropbox Basic",
                ServiceDescriptionDE = "Dropbox bietet Speicherplatz für Dateien auf all Ihren verknüpften Geräten",
                ServiceTitleDE       = "Kostenlose Version von Dropbox",
                CloudServiceModelId  = saaSModel.Id,
                CloudServiceModel    = saaSModel,
                ProviderId           = dropboxProvider.Id,
                Provider             = dropboxProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                }
            }
                );
            context.OnlineDriveStorageService.AddOrUpdate(
                x => x.ServiceName,
                new OnlineDriveStorageService
            {
                ServiceName          = "OneDrive",
                ServiceDescriptionDE = "Speichern Sie Ihre Dateien und Fotos auf OneDrive, um sie von jedem Gerät und überall aus abrufen zu können",
                CloudServiceModelId  = saaSModel.Id,
                CloudServiceModel    = saaSModel,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                }
            }
                );
            context.OnlineDriveStorageService.AddOrUpdate(
                x => x.ServiceName,
                new OnlineDriveStorageService {
                ServiceName          = "HiDrive",
                ServiceDescriptionDE = "Der Cloud-Speicher für Ihre Fotos, Videos & Dateien",
                ServiceTitleDE       = "HiDrive",
                ServiceAvailability  = "99,99",
                CloudServiceModelId  = saaSModel.Id,
                CloudServiceModel    = saaSModel,
                ProviderId           = stratoProvider.Id,
                Provider             = stratoProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                }
            }
                );
            context.ObjectStorageService.AddOrUpdate(
                x => x.ServiceName,
                new ObjectStorageService {
                ServiceName          = "Amazon S3",
                ServiceDescriptionDE = "Filehosting-Dienst, der beliebig große Datenmengen speichern kann und nach Verbrauch abgerechnet wird",
                ServiceTitleDE       = "Amazon Simple Storage Service",
                ServiceAvailability  = "99,99",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasFileEncryption, hasVersioning, hasPermissions, hasReplication, hasLocking
                }
            }
                );
            context.ObjectStorageService.AddOrUpdate(
                x => x.ServiceName,
                new ObjectStorageService {
                ServiceName          = "Google Cloud Storage",
                ServiceDescriptionDE = "Einheitlicher Objektspeicher für Entwickler und Unternehmen",
                ServiceTitleDE       = "Google Cloud Storage",
                ServiceAvailability  = "99,99",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                ProviderId           = googleProvider.Id,
                Provider             = googleProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasFileEncryption, hasVersioning, hasPermissions
                }
            }
                );
            context.BlockStorageService.AddOrUpdate(
                x => x.ServiceName,
                new BlockStorageService {
                ServiceName          = "Azure Disk Storage",
                ServiceDescriptionDE = "Persistente und leistungsstarke Datenträger für virtuelle Azure-Computer",
                ServiceAvailability  = "99,95",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                }
            }
                );
            context.ObjectStorageService.AddOrUpdate(
                x => x.ServiceName,
                new ObjectStorageService {
                ServiceName         = "S3 Object Storage",
                ServiceAvailability = "99,95",
                CloudServiceModelId = iaaSModel.Id,
                CloudServiceModel   = iaaSModel,
                Creation            = DateTime.Now,
                LastModified        = DateTime.Now,
                Features            = new List <Feature> {
                    hasFileEncryption, hasPermissions
                }
            }
                );
            context.BlockStorageService.AddOrUpdate(
                x => x.ServiceName,
                new BlockStorageService {
                ServiceName          = "Amazon Elastic Block Store",
                ServiceDescriptionDE = "Amazon Elastic Block Store (Amazon EBS) bietet Volumes für die Speicherung auf Blockebene, die in Verbindung mit EC2-Instances verwendet werden. EBS-Volumes verhalten sich wie unformatierte Blockgeräte",
                ServiceTitleDE       = "Amazon EBS",
                ServiceAvailability  = "99,99",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                ProviderId           = awsProvider.Id,
                Provider             = awsProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasFileEncryption, hasReplication
                }
            }
                );
            context.BlockStorageService.AddOrUpdate(
                x => x.ServiceName,
                new BlockStorageService {
                ServiceName          = "Blockspeicher für VM-Instanzen",
                ServiceDescriptionDE = "Zuverlässiger, leistungsstarker Blockspeicher für VM-Instanzen",
                ServiceTitleDE       = "Persistent Disk",
                ServiceAvailability  = "99,99",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                ProviderId           = googleProvider.Id,
                Provider             = googleProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasFileEncryption, hasReplication
                }
            }
                );
            context.BlockStorageService.AddOrUpdate(
                x => x.ServiceName,
                new BlockStorageService {
                ServiceName          = "Azure Disk Storage",
                ServiceDescriptionDE = "Persistente und leistungsstarke Datenträger für virtuelle Azure-Compute",
                ServiceTitleDE       = "Azure Disk Storage",
                ServiceAvailability  = "99,99",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                ProviderId           = azureProvider.Id,
                Provider             = azureProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasFileEncryption, hasReplication
                }
            }
                );
            context.ObjectStorageService.AddOrUpdate(
                x => x.ServiceName,
                new ObjectStorageService {
                ServiceName          = "Blob Storage",
                ServiceDescriptionDE = "Hochgradig skalierbarer Objektspeicher für unstrukturierte Daten",
                ServiceTitleDE       = "Blob Storage",
                ServiceAvailability  = "99,99",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasPermissions, hasReplication
                }
            }
                );
            context.ObjectStorageService.AddOrUpdate(
                x => x.ServiceName,
                new ObjectStorageService {
                ServiceName          = "Spaces",
                ServiceDescriptionDE = "Spaces ergänzt den lokalen und Netzwerkspeicher, um Ihrem Unternehmen die Skalierung zu erleichtern",
                ServiceTitleDE       = "Spaces",
                ServiceAvailability  = "99,95",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                ProviderId           = digitalOceanProvider.Id,
                Provider             = digitalOceanProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasPermissions, hasReplication
                }
            }
                );
            context.BlockStorageService.AddOrUpdate(
                x => x.ServiceName,
                new BlockStorageService {
                ServiceName          = "Volumes Block Storage",
                ServiceDescriptionDE = "Hochverfügbaren und skalierbaren SSD-basierten Blockspeicher",
                ServiceTitleDE       = "Volumes Block Storage",
                ServiceAvailability  = "99,95",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                ProviderId           = digitalOceanProvider.Id,
                Provider             = digitalOceanProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasReplication
                }
            }
                );
            context.BlockStorageService.AddOrUpdate(
                x => x.ServiceName,
                new BlockStorageService {
                ServiceName          = "Volumes",
                ServiceDescriptionDE = "Volumes bieten hochverfügbaren und zuverlässigen SSD-Speicherplatz für Ihre Cloud Server",
                ServiceTitleDE       = "Volumes",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                ProviderId           = hetznerProvider.Id,
                Provider             = hetznerProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasReplication
                }
            }
                );
            context.OnlineDriveStorageService.AddOrUpdate(
                x => x.ServiceName,
                new OnlineDriveStorageService {
                ServiceName          = "Storage Share",
                ServiceDescriptionDE = "Daten speichern und teilen",
                ServiceTitleDE       = "Storage Share",
                ServiceTitleEN       = "Storage Share",
                ServiceTitleES       = "Storage Share",
                CloudServiceModelId  = saaSModel.Id,
                CloudServiceModel    = saaSModel,
                ProviderId           = hetznerProvider.Id,
                Provider             = hetznerProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                }
            }
                );
            context.ObjectStorageService.AddOrUpdate(
                x => x.ServiceName,
                new ObjectStorageService {
                ServiceName          = "Cloud Files",
                ServiceDescriptionDE = "Cloud Files bietet Online-Objektspeicher für Dateien und Medien und stellt sie weltweit mit rasender Geschwindigkeit über ein weltweites Content-Delivery-Netzwerk (CDN) bereit",
                ServiceAvailability  = "99,99",
                ServiceTitleDE       = "Cloud Files",
                ServiceTitleEN       = "Cloud Files",
                ServiceTitleES       = "Cloud Files",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasPermissions, hasReplication
                }
            }
                );
            context.BlockStorageService.AddOrUpdate(
                x => x.ServiceName,
                new BlockStorageService {
                ServiceName          = "Cloud Block Storage",
                ServiceDescriptionDE = "Cloud Block Storage bietet zuverlässigen, leistungsstarken On-Demand-Speicher für Anwendungen, die auf Cloud-Servern gehostet werden",
                ServiceTitleDE       = "Cloud Block Storage",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                ProviderId           = rackspaceProvider.Id,
                Provider             = rackspaceProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasFileEncryption, hasReplication
                }
            }
                );
            context.ObjectStorageService.AddOrUpdate(
                x => x.ServiceName,
                new ObjectStorageService {
                ServiceName          = "Cloud Object Storage",
                ServiceDescriptionDE = "Stelle deine Daten von überall aus wieder her oder mache Backups einfach über unseren redundanten Objekt Storage mit S3-kompatibler Schnittstelle",
                ServiceTitleDE       = "Cloud Object Storage",
                ServiceAvailability  = "99,95",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasPermissions
                }
            }
                );
            context.ObjectStorageService.AddOrUpdate(
                x => x.ServiceName,
                new ObjectStorageService {
                ServiceName          = "IBM Cloud Object Storage",
                ServiceDescriptionDE = "IBM Cloud Object Storage wurde entwickelt, um ein exponentielles Datenwachstum und Cloud-native Arbeitslasten zu unterstützen",
                ServiceTitleDE       = "IBM Cloud Object Storage",
                ServiceAvailability  = "99,99",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                ProviderId           = ibmProvider.Id,
                Provider             = ibmProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasPermissions, hasReplication
                }
            }
                );
            context.BlockStorageService.AddOrUpdate(
                x => x.ServiceName,
                new BlockStorageService {
                ServiceName          = "IBM Block Storage",
                ServiceDescriptionDE = "Flash-basierter, leistungsstarker lokaler Plattenspeicher mit SAN-Persistenz und -Beständigkeit, anpassbaren E/A-Operationen pro Sekunde und kalkulierbaren Kosten",
                ServiceTitleDE       = "IBM Block Storage",
                ServiceAvailability  = "99,99",
                CloudServiceModelId  = iaaSModel.Id,
                CloudServiceModel    = iaaSModel,
                ProviderId           = ibmProvider.Id,
                Provider             = ibmProvider,
                Creation             = DateTime.Now,
                LastModified         = DateTime.Now,
                Features             = new List <Feature> {
                    hasFileEncryption, hasReplication
                }
            }
                );

            context.SaveChanges();
        }
コード例 #39
0
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();

			switch (version)
			{
				case 2:
					{
						m_PricingModel = (PricingModel)reader.ReadInt();
						goto case 1;
					}
				case 1:
					{

						House = (BaseHouse)reader.ReadItem();
						goto case 0;
					}
				case 0:
					{
						m_Owner = reader.ReadMobile();
						m_BankAccount = reader.ReadInt();
						m_HoldGold = reader.ReadInt();

						int count = reader.ReadInt();
						m_SellItems = new Hashtable();
						for (int i = 0; i < count; i++)
						{
							Item item = reader.ReadItem();
							int p = reader.ReadInt();
							string d = reader.ReadString();

							if (item != null && !item.Deleted)
								m_SellItems[item] = new VendorItem(item, p, d);
						}
						break;
					}
			}

			if (version < 1)
			{

				House = BaseHouse.FindHouseAt(this);
			}

			m_PayTimer = new PayTimer(this);
			m_PayTimer.Start();

			Blessed = false;

			if (Core.AOS && NameHue == 0x35)
				NameHue = -1;
		}
コード例 #40
0
 public void PricingModelConstructorTest_nullPricingParameter_emptyResultsReturned() {
     PricingModel pricingModel = new PricingModel(null);            
     Assert.AreEqual(0, pricingModel.GetCountOfPricings);
 }
コード例 #41
0
 public void GetItemPriceTest_invalidPricingFormat_priceInvalid_nonNumeric_exceptionExpected() {
     PricingModel pricingModel = new PricingModel(new string[0]);
     pricingModel.GetItemPrice("Apple, A");
 }
コード例 #42
0
 public void GetItemPriceTest_invalidPricingFormat_priceInvalid_negativePrice_exceptionExpected() {
     PricingModel pricingModel = new PricingModel(new string[0]);
     pricingModel.GetItemPrice("Apple, -1.00");
 }