Esempio n. 1
0
        public void BasicTest()
        {
            var material = new Material()
                {
                    Name = "M1",
                    Price = 0.5f,
                    Ammount = 2
                };
            var material1 = new Material()
                {
                    Name = "M2",
                    Price = 1f,
                    Ammount = 1
                };

            var bpo = new Blueprint()
                {
                    SellPrice = 4,
                    Runs = 10
                };
            bpo.Materials = new Materials(new List<Material>()
                {
                    material,
                    material1
                }, bpo);

            Assert.AreEqual(bpo.ItemProductionPrice, 2, "Неверно вычисляется цена запуска");
            Assert.AreEqual(bpo.TotalPrice, 2*10, "Неверно вычисляется общая цена");
            Assert.AreEqual(bpo.Income, 4*10 - 2*10, "Неверно вычисляется доход");
        }
Esempio n. 2
0
        public void Init()
        {
            var newButtonContent= new StackPanel()
                {
                    Orientation = Orientation.Horizontal,
                };
            var bpTextBox = new TextBox()
                {
                    MinWidth = 100,
                    MaxWidth = 300
                };
            var button = new Button()
                {
                    Content = "Новый чертеж",
                };
            button.Click += (s, e) =>
                {
                    var bp = new Blueprint()
                        {
                            Name = string.IsNullOrEmpty(bpTextBox.Text) ? "Новый чертеж" : bpTextBox.Text.Trim(),
                            Runs = 1
                        };
                    _blueprints.Add(bp);
                    BPList.SelectedItem = bp;
                    BPList.ScrollIntoView(bp);
                    bpDetails.DownloadMaterialsClick(null, null);
                };
            newButtonContent.Children.Add(bpTextBox);
            newButtonContent.Children.Add(button);

               Commands = new List<PageCommand>()
                {
                    new PageCommand
                        {
                            Name = "Сохранить",
                            Action = p =>
                                {
                                    using (var r = _blueprintsRepos())
                                    {
                                        using (var transaction = new TransactionScope())
                                        {
                                            var toStore =
                                                _blueprints.Where(bp => _toRemove.All(tr => tr.Guid != bp.Guid));

                                            r.StoreBulk(toStore);
                                            r.SaveChanges();

                                            foreach (var toRem in _toRemove)
                                            {
                                                r.DeleteById(toRem.Id);
                                            }
                                            r.SaveChanges();
                                            transaction.Complete();
                                        }
                                    }
                                }
                        },
                    new PageCommand
                        {
                            Name = "Загрузить",
                            Action = p => Load()
                        },
                    new PageCommand
                        {
                            Name = "Новый",
                            Content=newButtonContent,
                        },
                    new PageCommand
                        {
                            Name = "Удалить",
                            Action = p =>
                                {
                                }
                        },
                    new PageCommand
                        {
                            Name = "Произвести",
                            Action = p =>
                                {
                                    var curBp = bpDetails.Blueprint;
                                    using (var repos=_prudoctionInfoRepos())
                                    {
                                        ProductionInfo prodIndo = curBp.MakeProduct();
                                        prodIndo.ProducingIn = "Kino";
                                        prodIndo.SellingIn = "Jita";
                                        repos.Store(prodIndo);
                                        repos.SaveChanges();
                                    }
                                }
                        }
                }.ToArray();

            Load();
            //throw new NotImplementedException();
        }
Esempio n. 3
0
        public static MaterialDetails LoadMaterials(Blueprint blueprint)
        {
            var url =
                string.Format(@"http://odylab-evedb.appspot.com/blueprintDetailsForTypeName/" +
                              HttpUtility.UrlEncode(blueprint.Name));

            var res = GetWholeResponce(url);

            /*ExpandoObject dynamic=new ExpandoObject();
            var res1=JsonConvert.DeserializeAnonymousType(res,dynamic);*/

            var matInfo = JsonConvert.DeserializeObject<MaterialDetails>(res);

            UpdateMaterials(matInfo);
            return matInfo;
            //res = JsonConvert.SerializeObject(res1, Formatting.Indented);
        }