コード例 #1
0
        public bool Post(ProductNew item)
        {
            try
            {
                List <Product> list = Get();

                Product cate = new Product
                {
                    auctiontime    = item.auctiontime,
                    bigimage       = item.bigimage,
                    brand          = item.brand,
                    catename       = item.catename,
                    idpro          = Guid.NewGuid(),
                    name           = item.name,
                    note           = item.note,
                    smallimage1    = item.smallimage1,
                    smallimage2    = item.smallimage2,
                    smallimage3    = item.smallimage3,
                    warrantyperiod = item.warrantyperiod,
                };
                this._context.PdbProduct.Add(cate);
                this._context.Entry(cate).State = Microsoft.EntityFrameworkCore.EntityState.Added;
                this._context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #2
0
        public ActionResult Giay()
        {
            var Product = new ProductNew();

            ViewBag.ProductNew = Product.ListNewProduct();
            return(View());
        }
コード例 #3
0
        public ActionResult QuanAo()
        {
            var Product = new ProductNew();

            ViewBag.ProductNew = Product.QuanAo();
            return(View());
        }
コード例 #4
0
        public ActionResult DoNewProduct(ProductNew model)
        {
            try
            {
                decimal d;
                var     productPdo = new Domain.Entities.Product();
                productPdo.PosId        = model.PosId;
                productPdo.CategoryId   = model.CategoryId;
                productPdo.Name         = HttpUtility.HtmlEncode(model.ProductName);
                productPdo.CreatedAt    = DateTime.UtcNow;
                productPdo.UserId       = "gj";
                productPdo.StatusId     = (byte)Status.Pending;
                productPdo.InternalCode = model.InternalCode.StartsWith(productPdo.UserId, StringComparison.InvariantCultureIgnoreCase) ? model.InternalCode : String.Concat(productPdo.UserId.ToUpper(), "_ES_", model.InternalCode);
                productPdo.Uid          = string.Concat("GJ_ES_", model.InternalCode);
                if (decimal.TryParse(model.PriceStr, out d))
                {
                    productPdo.Price = d;
                }

                _productRepository.Save(productPdo);
                _productRepository.SubmitChanges();

                var product = new Product(productPdo);

                ViewBag.TotalSizes = model.TotalSizes;
                return(PartialView(product));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #5
0
        public ActionResult Phukien()
        {
            var Product = new ProductNew();

            ViewBag.ProductNew = Product.Phukien();
            return(View());
        }
コード例 #6
0
        public ActionResult Index()
        {
            var Product = new ProductNew();

            ViewBag.ProductNew        = Product.ListNewProduct(12);
            ViewBag.ProductBestSeller = Product.BestsellerProduct(12);
            return(View());
        }
コード例 #7
0
        public IHttpActionResult GetProductNew(int id)
        {
            ProductNew productnew = db.ProductNew.Find(id);

            if (productnew == null)
            {
                return(NotFound());
            }

            return(Ok(productnew));
        }
コード例 #8
0
 public bool UpdateProd(ProductNew prod_new)
 {
     try
     {
         return(this.Product_dal.Update(prod_new));
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #9
0
 public bool InsertProd(ProductNew prod_new)
 {
     try
     {
         return(this.Product_dal.Insert(prod_new));
     }
     catch (Exception ex)
     {
         throw new Exception($"ProductService:{ex.Message}");
     }
 }
コード例 #10
0
        // GET api/EndUserUpdate/5

        //original
        //[ResponseType(typeof(Update))]
        //public IHttpActionResult GetUpdate(int id)
        //{
        //    Update update = db.Update.Find(id);
        //    if (update == null)
        //    {
        //        return NotFound();
        //    }

        //    return Ok(update);
        //}



        public IHttpActionResult GetUpdate(int id)
        {
            ProductNew pn = db.ProductNew
                            .Include(i => i.Updates).Where(i => i.ProductID == id)
                            .Single();
            //var endUserProducts = new HashSet<int>(endUser.ProductNews.Select(c => c.ProductID));
            var abc = PopulateAssignedUpdateData(pn);

            return(Ok(abc));
            //original
            //return db.EveryBody;
        }
コード例 #11
0
        public void RunNewProduct(ShopifyNewProductImportContext context)
        {
            if (MonsterConfig.Settings.DisableShopifyPut)
            {
                _logService.Log(LogBuilder.ShopifyPutDisabled());
                return;
            }

            var newVariants = CleanAndBuildVariantPayload(context.AcumaticaItemIds);

            var product = new ProductNew()
            {
                title        = context.ProductTitle,
                vendor       = context.ProductVendor,
                product_type = context.ProductType,
                variants     = new List <ShopifyVariantNew>()
            };
            var parent = new { product = product };

            product.variants = newVariants;

            // POST new Product via Shopify API
            //
            var result           = _productApi.CreateProduct(parent.SerializeToJson());
            var resultProduct    = result.DeserializeFromJson <ProductParent>();
            var shopifyProductId = resultProduct.product.id;

            // Run ShopifyInventoryGet to pull into local cache
            //
            _shopifyInventoryGet.Run(shopifyProductId);
            var productRecord = _syncInventoryRepository.RetrieveProduct(shopifyProductId);

            // Execution Log entry
            //
            var log = LogBuilder.CreatedShopifyProduct(productRecord);

            _logService.Log(log);

            // Create Sync Records for the Variants that were created
            //
            foreach (var newVariant in newVariants)
            {
                var variantRecord = productRecord.ShopifyVariants.FirstOrDefault(x => x.ShopifySku == newVariant.sku);
                CreateSyncRecord(newVariant.sku, variantRecord);
            }

            // Update Inventory data
            //
            foreach (var itemId in context.AcumaticaItemIds)
            {
                RunInventoryUpdate(itemId);
            }
        }
コード例 #12
0
        /// <summary>
        /// 取得產品細節
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        public ProductNew GetProductDetail(int num)
        {
            ProductNew result = null;

            try
            {
                return(this.Product_dal.Get(num));
            }
            catch (Exception ex)
            {
                return(result);
            }
        }
コード例 #13
0
ファイル: ProductDAL.cs プロジェクト: eggeggss/OfficialCore
        public bool Insert(ProductNew product)
        {
            {
                Func <bool> func = new Func <bool>(() => {
                    _entity.Entry(product).State = EntityState.Added;

                    _entity.SaveChanges();

                    return(true);
                });

                return(_adapter.Catch <bool>(func));
            }
        }
コード例 #14
0
        public IHttpActionResult DeleteProductNew(int id)
        {
            ProductNew productnew = db.ProductNew.Find(id);

            if (productnew == null)
            {
                return(NotFound());
            }

            db.ProductNew.Remove(productnew);
            db.SaveChanges();

            return(Ok(productnew));
        }
コード例 #15
0
ファイル: ProductDAL.cs プロジェクト: eggeggss/OfficialCore
        public bool Update(ProductNew product)
        {
            {
                Func <bool> func = new Func <bool>(() => {
                    if (product.Person != null)
                    {
                        product.Person = product.Person.Trim();
                    }
                    _entity.Entry(product).State = EntityState.Modified;
                    _entity.SaveChanges();

                    return(true);
                });

                return(_adapter.Catch <bool>(func));
            }
        }
コード例 #16
0
ファイル: ProductDAL.cs プロジェクト: eggeggss/OfficialCore
        public bool Delete(ProductNew product)
        {
            {
                Func <bool> func = new Func <bool>(() => {
                    var ProductNew = _entity.ProductNew
                                     .Where(e => e.Num == product.Num).FirstOrDefault();

                    _entity.ProductNew.Remove(product);

                    _entity.SaveChanges();

                    return(true);
                });

                return(_adapter.Catch <bool>(func));
            }
        }
コード例 #17
0
        public IHttpActionResult PostProductNew(AssignedProductData productnew)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var          e  = User.Identity.Name;
            ProductOwner po = db.ProductOwner.FirstOrDefault(d => d.Email == e);
            ProductNew   pn = new ProductNew()
            {
                ProductName     = productnew.ProductName,
                ProductOwner_ID = po.ID
            };

            db.ProductNew.Add(pn);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = productnew.ProductID }, productnew));
        }
コード例 #18
0
        private List <Update> PopulateAssignedUpdateData(ProductNew pn)
        {
            var allUpdates   = db.Update;
            var ownerupdates = new HashSet <int>(pn.Updates.Select(c => c.UpdateID));
            var viewModel    = new List <Update>();

            foreach (var update in allUpdates)
            {
                if (ownerupdates.Contains(update.UpdateID))
                {
                    viewModel.Add(new Update
                    {
                        UpdateID     = update.UpdateID,
                        UpdateIntro  = update.UpdateIntro,
                        UpdateDetail = update.UpdateDetail
                                       // Assigned = ownerupdates.Contains(product.ProductID)
                    });
                }
            }

            return(viewModel);
        }
コード例 #19
0
        // PUT api/productNew/5
        public IHttpActionResult PutProductNew(int id, ProductNew productnew)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != productnew.ProductID)
            {
                return(BadRequest());
            }

            var          e  = User.Identity.Name;
            ProductOwner po = db.ProductOwner.FirstOrDefault(d => d.Email == e);

            productnew.ProductOwner_ID = po.ID;


            db.Entry(productnew).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductNewExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #20
0
        /// <summary>
        /// Displays new product form (fro Ajax)
        /// </summary>
        /// <param name="id">POS ID</param>
        public ActionResult GetNewProduct(int id)
        {
            try
            {
                var model = new ProductNew();
                var pos   = _organizationRepository.GetById(id);
                model.PosId      = pos.Id;
                model.PosName    = pos.Name;
                model.CategoryId = int.Parse(Request["categoryId"]);
                model.TotalSizes = HasRequestParameter("sizes") ? int.Parse(Request["sizes"]) : 0;
                var category = _productRepository.Categories.First(x => x.Id == model.CategoryId);
                //.Select(x => new Category { Id = x.Id, Name = x.Name })
                //.First(x => x.Equals(model.CategoryId));
                model.CategoryName = category.Name;

                return(PartialView(model));
            }
            catch (Exception ex)
            {
                Error("Error getting new product form", ex);
                throw;
            }
        }