Exemplo n.º 1
0
        public void GenProducts()
        {
            int num = 1;

            proset = new ProductSet();
            foreach (Train t in tt)
            {
                foreach (StopStation ss in t.StaList)
                {
                    for (int i = t.StaList.IndexOf(ss); i < t.StaList.Count - 1; i++)
                    {
                        Product p = new Product()
                        {
                            ProID        = num++,
                            StartStation = ss.StationName,
                            EndStation   = t.StaList[i + 1].StationName,
                            Train        = t
                        };
                        double f = 0;
                        for (int j = t.StaList.IndexOf(ss) + 1; j <= i + 1; j++)
                        {
                            f += (t.StaList[j].MileStone - t.StaList[j - 1].MileStone) * Math.Pow(settings.PriceDeclineRatio, j - t.StaList.IndexOf(ss) - 1);
                        }
                        p.Fare = f * t.PriceRatio;
                        for (int j = t.StaList.IndexOf(ss); j < i + 1; j++)
                        {
                            //p.Add(t.SecList[j]);
                        }
                        proset.Add(p);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void GenPro()
        {
            DataTable Pro = _ds.Tables["Pro"];

            proset = new ProductSet();
            foreach (DataRow dr in Pro.Rows)
            {
                Product p = new Product()
                {
                    ProID       = Convert.ToInt32(dr["ID"]),
                    Description = dr["Des"].ToString(),
                    Fare        = Convert.ToDouble(dr["Fare"])
                };
                string s = dr["Res"].ToString();

                foreach (string ss in s.Split(','))
                {
                    Resource temp = ResSet.Find(i => i.ResID == Convert.ToInt32(ss));
                    if (temp != null)
                    {
                        p.Add(temp);
                    }
                }

                proset.Add(p);
            }
        }
Exemplo n.º 3
0
        internal static Product ProductSetToProduct(this ProductSet product)
        {
            Mapper.Initialize(cfg => cfg.CreateMap <ProductSet, Product>());
            var result = Mapper.Map <ProductSet, Product>(product);

            return(result);
        }
Exemplo n.º 4
0
 private void InitCollections()
 {
     _unitGroups = new UnitGroupSet(this);
     _packages   = new PackageSet(this);
     _routes     = new RouteSet <Shape>(this);
     _products   = new ProductSet <Shape>(this);
 }
Exemplo n.º 5
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProductSet productSet = db.ProductSet.Find(id);

            db.ProductSet.Remove(productSet);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public void setData(ProductSet data)
 {
     this.data = data;
     this.button.Text = this.data.name.ToString();
     this.label1.Text = this.data.count.ToString();
     this.label2.Text = this.data.cost.ToString();
     this.Enabled = this.data.count > 0;
 }
Exemplo n.º 7
0
 public void ClearAll()
 {
     tt       = null;
     this.mar = null;
     pathList = null;
     proset   = null;
     rs       = null;
 }
Exemplo n.º 8
0
        public void AddProductSetTest()
        {
            var p = ProductSet.Random();
            var c = ProductSets.Instance.Count;

            Obj.AddProductSet(p);
            Assert.AreEqual(c + 1, ProductSets.Instance.Count);
            Assert.AreEqual(p, ProductSets.Instance.Find(x => x.IsSameContent(p)));
        }
Exemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "Id,Name,Price,Description")] ProductSet productSet)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productSet).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(productSet));
 }
Exemplo n.º 10
0
        public ActionResult Create([Bind(Include = "Id,Name,Price,Description")] ProductSet productSet)
        {
            if (ModelState.IsValid)
            {
                db.ProductSet.Add(productSet);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(productSet));
        }
Exemplo n.º 11
0
        public ActionResult CreateProductSet(string name, string description)
        {
            var productSet = new ProductSet();

            if (TryUpdateModel(productSet))
            {
                Repository.Data.Save(productSet);
            }

            return(View("ProductSetView", GetProductSets()));
        }
Exemplo n.º 12
0
        public void Initialyze()
        {
            path = Path.Combine(boot.DebugDir, "Prices");
            ps   = new ProductSet(boot);
            psi  = new psInit(boot);
            _U   = new _UT_ProductSet(boot);
            _I   = new _UT_psInit(boot);

            ////////////if (boot.Suppliers == null) System.Threading.Thread.Sleep(1000);
            //18/2//////Assert.IsNotNull(boot.Suppliers);
            ////////////gs.Init(boot);
        }
Exemplo n.º 13
0
        public ActionResult SaveUpdateProductSet(Guid productSetId)
        {
            var productSet = new ProductSet();

            if (TryUpdateModel(productSet))
            {
                var originProductSet = Repository.Data.Get <ProductSet>(productSetId);
                originProductSet.Name        = productSet.Name;
                originProductSet.Description = productSet.Description;
                Repository.Data.Save(originProductSet);
            }
            return(Index());
        }
Exemplo n.º 14
0
        // GET: Products/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductSet productSet = db.ProductSet.Find(id);

            if (productSet == null)
            {
                return(HttpNotFound());
            }
            return(View(productSet));
        }
Exemplo n.º 15
0
        private void PSU(string name, string FileName,
                         string validDate, int i0, string LoadDescr, params string[] rl)
        {
            var ps  = new ProductSet(boot);
            var psi = new psInit(boot);

            ps.name      = psi.name = psi.SheetN = name;
            ps.SuplName  = supl.name;
            psi.FileName = FileName;
            //            psi.SheetN = SheetN;
            if (!DateTime.TryParse(validDate, out ps.ValidUntil))
            {
                ps.ValidUntil = Declaration.MinDate;
            }
            psi.i0             = i0;
            psi.LoadDescriptor = LoadDescr;
            ps.RuleText        = rl.ToList();
            ps.Update(psi);
        }
Exemplo n.º 16
0
        public IList <Product> GetProductList(string nameCode, string group, int selection)
        {
            ProductSet prodset = ControllerManager.ProductSet.GetProductSet(selection);
            ICriteria  crit    = GetCriteria();

            if (nameCode != null)
            {
                crit.Add(new OrExpression(new LikeExpression("ProductCode", nameCode, MatchMode.Anywhere), new LikeExpression("Description", nameCode, MatchMode.Anywhere)));
            }
            if (group != null)
            {
                crit.Add(new EqExpression("Group", group));
            }
            if (selection > 0)
            {
                crit.Add(new EqExpression("ProductSets", prodset));
            }

            return(crit.List <Product>());
        }
Exemplo n.º 17
0
        public async Task <IActionResult> Create(ProductSetViewmodel model)
        {
            try
            {
                var division = await context.Divisions.FindAsync(model.DivisionId);

                if (division == null)
                {
                    return(NotFound(new { message = $"Company division with ID {model.DivisionId} was not found." }));
                }

                var set = new ProductSet
                {
                    Division = division,
                    Name     = model.Name
                };
                var products = new List <Product>();
                foreach (var p in model.Products)
                {
                    var product = await context.Products.FindAsync(p.Id);

                    if (product == null)
                    {
                        return(NotFound(new { message = $"Product with ID {p.Id} ({p.Name}) was not found." }));
                    }
                    products.Add(product);
                }
                set.Products = products;

                await context.ProductSets.AddAsync(set);

                await context.SaveChangesAsync();

                return(Ok(set));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Unable to create product set", ex);
                return(BadRequest(ex.ToString()));
            }
        }
Exemplo n.º 18
0
        private void si(string suplName, string psName, string FileName, string SheetN, string LoadDescriptor)
        {
            Supplier supl = boot.Suppliers.AllSuppliers.Find(x => x.name == suplName);

            Assert.IsNotNull(supl, $"UT: Bad suplName={suplName}");
            suplInit = boot.ssInit.Find(x => x.name == suplName);
            if (suplInit == null)
            {
                suplInit = new SupplierInit(boot);
                ProductSet ps = supl.productSets.Find(x => x.name == psName);
                if (ps == null)
                {
                    ps      = new ProductSet(boot);
                    ps.name = psName;
                }
                psInit psi = new psInit(boot);
                psi.Copy(ps, FileName, SheetN, LoadDescriptor);
                suplInit.Copy(supl);
                suplInit.productSets.Add(psi);
            }
        }
Exemplo n.º 19
0
        public void UT_Update()
        {
            //          ps.Update("СтальХолдинг");



            string   suplName     = "СтальХолдинг";
            string   psName       = "Лист";
            var      AllSuppliers = boot.Suppliers.AllSuppliers;
            Supplier supl         = AllSuppliers.Find(x => x.name == suplName);

            ps = supl.productSets.Find(x => x.name.Contains(psName));
            var supl_I = boot.ssInit.Find(x => x.name == suplName);
            var psi    = supl_I.pssInit.Find(x => x.name.Contains(psName));

            ps.Update(psi);

            Assert.AreEqual(ps.name, psName);
            Assert.AreEqual(ps.SuplName, suplName);
            Assert.IsTrue(ps.Products.Count > 1);
        }
Exemplo n.º 20
0
        public async Task <IActionResult> OnPostAsync()
        {
            try
            {
                var division = await context.Divisions.FindAsync(ProductSet.DivisionId);

                var set = new ProductSet
                {
                    Division = division,
                    Name     = ProductSet.Name
                };

                var products = new List <Product>();
                foreach (var p in ProductSet.Products)
                {
                    var product = await context.Products.FindAsync(p.Id);

                    products.Add(product);
                }
                set.Products = products;

                await context.ProductSets.AddAsync(set);

                await context.SaveChangesAsync();

                return(Redirect("Index"));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Unable to save appointment: {ex}", ex);
                SaveSetErrorMessage = ex.ToString();
                SaveSetError        = true;

                return(Page());
            }
        }
Exemplo n.º 21
0
 private void InitializeCollections()
 {
     _products = new ProductSet <Brand>(this);
 }
Exemplo n.º 22
0
 public Task SaveProductSetAsync(ProductSet ProductSet, Guid TemplateId)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 23
0
 public void SaveProductSet(ProductSet ProductSet, Guid TemplateId)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 24
0
 public ProductView GetOne(int id) => ProductSet.Where(x => x.Id == id).FirstOrDefault();
Exemplo n.º 25
0
 public IEnumerable <ProductView> GetAllForOwner(int ownerId) => ProductSet.Where(x => x.CreatedBy.Id == ownerId).ToList();
Exemplo n.º 26
0
 private void InitializeCollections()
 {
     _shapes   = new ShapeSet <Package>(this);
     _products = new ProductSet <Package>(this);
 }
Exemplo n.º 27
0
        /// <summary>
        /// Modifies the set of products a user is entitled to access.
        /// Documentation https://developers.google.com/androidenterprise/v1/reference/users/setAvailableProductSet
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated AndroidEnterprise service.</param>
        /// <param name="enterpriseId">The ID of the enterprise.</param>
        /// <param name="userId">The ID of the user.</param>
        /// <param name="body">A valid AndroidEnterprise v1 body.</param>
        /// <returns>ProductSetResponse</returns>
        public static ProductSet SetAvailableProductSet(AndroidEnterpriseService service, string enterpriseId, string userId, ProductSet body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (enterpriseId == null)
                {
                    throw new ArgumentNullException(enterpriseId);
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }

                // Make the request.
                return(service.Users.SetAvailableProductSet(body, enterpriseId, userId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Users.SetAvailableProductSet failed.", ex);
            }
        }
Exemplo n.º 28
0
 public IEnumerable <ProductView> GetAllForAdmin() => ProductSet.Where(x => x.State == ProductState.UnProcessed).ToList();
Exemplo n.º 29
0
 public IEnumerable <ProductBaseView> GetCatalog() => ProductSet.Where(x => x.State == ProductState.InCatalog).ToList();