Beispiel #1
0
        public override bool Init(Client client)
        {
            int productColorID;

            if (int.TryParse(BaseFuncs.GetAdditionalURLArray(client.URL, this.URL)[0], out productColorID))
            {
                ProductColor productColor = productColorService.GetByID(productColorID);
                if (productColor != null)
                {
                    Hashtable data = new Hashtable();

                    if (client.PostParam("EditProductColor") != null && client.PostParam("name") != null)
                    {
                        if (client.PostParam("RGB") != null)
                        {
                            productColorService.EditProductColor(client.PostParam("RGB"), client.PostParam("name"), productColorID);
                            client.Redirect("/product.color/#pr_" + productColor.ID);
                            Logger.ConsoleLog("Edited product color: " + productColor.RGB + " (ID: " + productColor.ID + ")", ConsoleColor.Yellow);

                            return(false);
                        }
                    }
                    data.Add("ProductColor", productColor);
                    client.HttpSend(TemplateActivator.Activate(this, client, data));
                    return(true);
                }
            }

            BaseFuncs.Show404(client);
            return(false);
        }
        public async Task <ActionResult <ProductColor> > PostProductColor(ProductColor productColor)
        {
            _context.ProductColors.Add(productColor);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProductColor", new { id = productColor.Pcid }, productColor));
        }
Beispiel #3
0
 private void GetFeatureValueType(Feature[] features, string field)
 {
     _colorTable = ProductColorTableFactory.GetColorTable(_subProductDef.ProductDef.Identify, "ISOT");//ISOT
     _legendItems.Clear();
     foreach (Feature fet in features)
     {
         string v = fet.GetFieldValue(field);
         if (v == null)
         {
             continue;
         }
         v = v.Trim();
         if (!_legendItems.ContainsKey(v))
         {
             ProductColor pc = GetColorByValue(v);
             if (pc != null)
             {
                 _legendItems.Add(pc.LableText, pc.Color);
             }
             else
             {
                 _legendItems.Add(v, Color.FromArgb(_random.Next(255), _random.Next(255), _random.Next(255)));
             }
         }
     }
 }
Beispiel #4
0
        public ProductColor AddProductColor(ProductColor productColor)
        {
            _context.ProductColors.Add(productColor);
            _context.SaveChanges();

            return(productColor);
        }
Beispiel #5
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="pro"></param>
        /// <returns></returns>
        public static int Edit(ProductColor pro)
        {
            PSSEntities db = new PSSEntities();

            db.Entry <ProductColor>(pro).State = System.Data.Entity.EntityState.Modified;
            return(db.SaveChanges());
        }
Beispiel #6
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="pro"></param>
        /// <returns></returns>
        public static int Add(ProductColor pro)
        {
            PSSEntities db = new PSSEntities();

            db.ProductColor.Add(pro);
            return(db.SaveChanges());
        }
        private void AddProductColor(IProductCommand command, Product product)
        {
            if (command.ProductColors == null)
            {
                return;
            }

            foreach (var item in command.ProductColors.Where(c => c.Name != null))
            {
                var color = new ProductColor
                {
                    Name         = item.Name,
                    CreationDate = DateTime.Now,
                    Creator      = command.UserIdentity.Email
                };

                if (item.IsNew)
                {
                    product.AddColor(color);
                }
                else
                {
                    var productColor = _productRepository.GetProductColorByValue(item.Name);
                    product.ProductColors.Add(productColor);
                }
            }
        }
Beispiel #8
0
        public async Task <IActionResult> PutProductColor(int id, ProductColor productColor)
        {
            if (id != productColor.Id)
            {
                return(BadRequest());
            }

            ProductColorValid valid = new ProductColorValid(_context, productColor);

            if (valid.Valid() == false)
            {
                return(BadRequest("Данное косметическое средство в этом цвете уже существует"));
            }

            _context.Entry(productColor).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductColorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        private List <ProductColor> GetColors(XElement productElement)
        {
            List <ProductColor> result = new List <ProductColor>();

            try
            {
                string genericDataElementValue = productElement.Element("generic_data").Value;
                string colors = genericDataElementValue.Replace("<![CDATA[", "").Replace("]]", "").Replace("\n", "");

                string[] colorsList = colors.Split(';');
                foreach (string color in colorsList)
                {
                    string[] colorParts = color.Split('=');

                    ProductColor productColor = new ProductColor();
                    productColor.Title = colorParts[0];
                    productColor.Value = colorParts[1];

                    result.Add(productColor);
                }
            }
            catch (Exception)
            {
            }

            return(result);
        }
        public async Task <IActionResult> PutProductColor(int id, ProductColor productColor)
        {
            if (id != productColor.Pcid)
            {
                return(BadRequest());
            }

            _context.Entry(productColor).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductColorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #11
0
        public async Task <IManagerActionResultModel <ProductColor> > CreateProductColorAsync(ICreateColorModel model)
        {
            var result = new ManagerActionResultModel <ProductColor>();

            try
            {
                var entity = new ProductColor()
                {
                    Name  = model.Name,
                    Value = model.Value
                };

                this.colorRepo.Add(entity);
                await this.colorRepo.SaveAsync();

                result.Succeeded = true;
                result.Model     = entity;
            }
            catch (Exception ex)
            {
                result.Errors.Add(new ErrorResultModel(ex));
                if (ex.InnerException != null)
                {
                    result.Errors.Add(new ErrorResultModel(ex.InnerException));
                }
            }

            return(result);
        }
Beispiel #12
0
        public async Task <IManagerActionResultModel <ProductColor> > UpdateProductColorAsync(IUpdateColorModel model)
        {
            var result = new ManagerActionResultModel <ProductColor>();

            try
            {
                ProductColor entity = await this.GetByIdAsync(model.Id);

                if (entity == null)
                {
                    result.Succeeded = false;
                    result.Errors.Add(new ErrorResultModel(string.Empty, "Product color not found!"));
                }

                entity.Name  = model.Name;
                entity.Value = model.Value;
                await this.colorRepo.SaveAsync();

                result.Succeeded = true;
                result.Model     = entity;
            }
            catch (Exception ex)
            {
                result.Errors.Add(new ErrorResultModel(ex));
                if (ex.InnerException != null)
                {
                    result.Errors.Add(new ErrorResultModel(ex.InnerException));
                }
            }

            return(result);
        }
Beispiel #13
0
        private void GetFeatureValueType(Feature[] features, string field)
        {
            _colorTable = ProductColorTableFactory.GetColorTable(_subProductDef.ProductDef.Identify, "ISOT");//ICE,ISOT
            _legendItems.Clear();

            foreach (Feature fet in features)
            {
                string v = fet.GetFieldValue(field);
                if (string.IsNullOrWhiteSpace(v))
                {
                    continue;
                }
                v = v.Trim();
                ProductColor pc = GetColorByValue(v);
                if (pc != null && !_legendItems.ContainsKey(v))
                {
                    _legendItems.Add(v, pc);
                }
                //else if(!_legendItems.ContainsKey(v))
                //    _legendItems.Add(v, Color.FromArgb(_random.Next(255), _random.Next(255), _random.Next(255)));
            }
            //温度按照从大到小排序.
            KeyValuePair <string, ProductColor>[] orderItems = _legendItems.OrderByDescending((item) => { return(item.Key); }).ToArray();
            _legendItems.Clear();
            foreach (KeyValuePair <string, ProductColor> v in orderItems)
            {
                _legendItems.Add(v.Key, v.Value);
            }
        }
Beispiel #14
0
 private ProductColor FillObject(ProductColor productColor)
 {
     productColor.Product         = GetProductEntity();
     productColor.ColorName       = txtProductColor.Text;
     productColor.ProductQuantity = Convert.ToInt32(txtProductQuantity.Value);
     return(productColor);
 }
Beispiel #15
0
        public ActionResult Edit(int pcid, int phid)
        {
            if (phid == 0)
            {
                return(Json(new
                {
                    Status = false,
                    Message = "圖檔未選取 !",
                }));
            }
            try
            {
                ProductColor pc = db.ProductColors.Find(pcid);

                pc.PhotoID = phid;

                db.Entry(pc).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    Status = false,
                    Message = ex.ToString(),
                }));
            }

            return(Json(new
            {
                Status = true,
                photoid = phid
            }));
        }
Beispiel #16
0
        public bool ShowDialog(ProductColor oProductColor, FormDisplayType displayType)
        {
            _displayType = displayType;
            switch (displayType)
            {
            case FormDisplayType.View:
                //ProductView(oProductColor);
                break;

            case FormDisplayType.Add:
                ProductAdd(oProductColor);
                break;

            case FormDisplayType.Edit:
                cboProduct.Enabled = false;
                ProductUpdate(oProductColor);
                break;

            case FormDisplayType.Delete:
                // ProductDelete(oProductColor);
                break;

            default:
                break;
            }

            this.ShowDialog();
            return(true);
        }
Beispiel #17
0
        public IActionResult UpdateProductColor(ProductColor productColor)
        {
            try
            {
                var _productColor = _repository.ProductColor.FindByCondition(c =>
                                                                             (c.Id == productColor.Id)).FirstOrDefault();
                if (_productColor == null)
                {
                    return(BadRequest("رنگ انتخابی وجود ندارد!"));
                }

                _productColor.Price   = productColor.Price;
                _productColor.Count   = productColor.Count;
                _productColor.Mdate   = DateTime.Now.Ticks;
                _productColor.MuserId = ClaimPrincipalFactory.GetUserId(User);
                _repository.ProductColor.Update(_productColor);
                _repository.Save();
                return(NoContent());
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
                return(BadRequest(e.Message));
            }
        }
        private void updateColros(int id, List <ColorModel> model)
        {
            List <ProductColor> colors = setzDB.ProductColors.Where(x => x.ProductID == id).ToList();

            foreach (var color in colors)
            {
                setzDB.ProductColors.Remove(color);
                setzDB.SaveChanges();
            }

            if (model != null)
            {
                foreach (var item in model)
                {
                    if (!string.IsNullOrEmpty(item.color))
                    {
                        ProductColor col = new ProductColor();
                        col.ProductID = id;
                        col.Hex       = item.color;
                        setzDB.ProductColors.Add(col);
                        setzDB.SaveChanges();
                    }
                }
            }
        }
Beispiel #19
0
 private void ProductAdd(ProductColor oProductColor)
 {
     btnUpdate.Visible = false;
     btnDelete.Visible = false;
     this.Text         = "Add product color";
     ClearControls();
 }
Beispiel #20
0
 public Product(String code, String name, ProductColor color, Decimal price, ProductSize size)
 {
     this._code  = code;
     this._name  = name;
     this._color = color;
     this._price = price;
     this._size  = size;
 }
Beispiel #21
0
 public void CreateProductColor(ProductColor t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository <ProductColor>();
         rep.Insert(t);
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            ProductColor productColor = db.ProductColors.Find(id);

            db.ProductColors.Remove(productColor);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #23
0
 public Product(string name, decimal price, ProductColor color, string description, int categoryId)
 {
     SetName(name);
     SetPrice(price);
     SetColor(color);
     SetDescription(description);
     SetCategory(categoryId);
 }
Beispiel #24
0
 private void ProductUpdate(ProductColor oProduct)
 {
     this.Text         = "Update product color";
     btnSave.Visible   = false;
     btnDelete.Visible = false;
     _productColor     = oProduct;
     FillControls(oProduct);
 }
Beispiel #25
0
 public IEnumerable<Product> ByColor(IList<Product> products, ProductColor productColor)
 {
     foreach (var product in products)
     {
         if (product.Color == productColor)
             yield return product;
     }
 }
Beispiel #26
0
 public IEnumerable<Product> ByColorAndSize(IList<Product> products, ProductColor productColor, ProductSize productSize)
 {
     foreach (var product in products)
     {
         if ((product.Color == productColor) && (product.Size == productSize))
             yield return product;
     }
 }
Beispiel #27
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            ProductColor productColor = await db.ProductColors.FindAsync(id);

            db.ProductColors.Remove(productColor);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
 private void UpdateListViewItem(ListViewItem lstItem, ProductColor productColor)
 {
     lstItem.Tag = productColor;
     lstItem.SubItems[0].BackColor = productColor.Color;
     lstItem.SubItems[1].Text      = productColor.LableText.ToString();
     lstItem.SubItems[2].Text      = productColor.MinValue.ToString();
     lstItem.SubItems[3].Text      = productColor.MaxValue.ToString();
     lstItem.SubItems[4].Text      = productColor.DisplayLengend.ToString();
 }
Beispiel #29
0
 public TochibaTVSet(uint price, ProductColor color, String name, double diagonal)
 {
     this.name           = name;
     this.category       = "TV set";
     this.color          = color;
     this.price          = price;
     this.screenDiagonal = diagonal;
     this.manufacturer   = "Tochiba";
 }
Beispiel #30
0
 public TochibaDishWasher(uint price, ProductColor color, String name, int capacityInKg)
 {
     this.name         = name;
     this.category     = "Dish washer";
     this.color        = color;
     this.price        = price;
     this.capacityInKg = capacityInKg;
     this.manufacturer = "Tochiba";
 }
Beispiel #31
0
 public TochibaFridge(uint price, ProductColor color, String name, bool hasFreezer)
 {
     this.name         = name;
     this.category     = "Fridge";
     this.color        = color;
     this.price        = price;
     this.hasFreezer   = hasFreezer;
     this.manufacturer = "Tochiba";
 }
Beispiel #32
0
 public TochibaWashingMachine(uint price, ProductColor color, String name, int rpmNum)
 {
     this.name         = name;
     this.category     = "Washing machine";
     this.color        = color;
     this.price        = price;
     this.rpmNumber    = rpmNum;
     this.manufacturer = "Tochiba";
 }
 public ColorAndSizeSpecification(ProductColor productColor, ProductSize productSize)
 {
     this.productColor = productColor;
     this.productSize = productSize;
 }
 public ColorFilterSpecification(ProductColor productColor)
 {
     this.productColor = productColor;
 }
 public ColorSpecification(ProductColor productColor)
 {
     _productColor = productColor;
 }
Beispiel #36
0
 public Product(ProductColor color, ProductSize size)
 {
     this.Color = color;
     this.Size = size;
 }
 public Product(ProductColor color)
 {
     this.Color = color;
 }