public async void Should_Not_Return_A_Product() { var s = new ProductSpec(1); var p = await this._df.ProductRepo.GetById(s); Assert.Null(p); }
public async Task <IActionResult> Edit(int id, [Bind("ProductSpecId,ProductId,categoryId,TagId,BrandId")] ProductSpec productSpec) { if (id != productSpec.ProductSpecId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(productSpec); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductSpecExists(productSpec.ProductSpecId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(productSpec)); }
public int Save(ProductSpec saveTemp) { saveTemp.Replace4MySQL(); StringBuilder stb = new StringBuilder("insert into product_spec (`spec_type`,`spec_name`,`spec_sort`,`spec_status`,`spec_id`,`spec_image`,`product_id`)"); stb.AppendFormat(" values({0},'{1}',{2},{3},{4},'{5}',{6})", saveTemp.spec_type, saveTemp.spec_name, saveTemp.spec_sort, saveTemp.spec_status, saveTemp.spec_id, saveTemp.spec_image, saveTemp.product_id); return _dbAccess.execCommand(stb.ToString()); }
/// <summary> /// 修改 /// </summary> /// <param name="pro"></param> /// <returns></returns> public static int Edit(ProductSpec pro) { PSSEntities db = new PSSEntities(); db.Entry <ProductSpec>(pro).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); }
public async Task <IActionResult> Edit(int id, [Bind("Value,ProductId,SpecificationId")] ProductSpec productSpec) { if (id != productSpec.SpecificationId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(productSpec); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductSpecExists(productSpec.SpecificationId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", productSpec.ProductId); ViewData["SpecificationId"] = new SelectList(_context.Specification, "Id", "Name", productSpec.SpecificationId); return(View(productSpec)); }
public override void Execute() { string _wsName = (string)ActionInParameterManager["WorkStationName"].GetValue(); ProductSpec productSpec = OwnerOrderList.GetLastProductType(_wsName); ActionOutParameterManager["ResultProductType"].SetValue(productSpec); }
/// <summary> /// 添加 /// </summary> /// <param name="pro"></param> /// <returns></returns> public static int Add(ProductSpec pro) { PSSEntities db = new PSSEntities(); db.ProductSpec.Add(pro); return(db.SaveChanges()); }
private ProductSpec createProductSpec() { ProductSpec p = new ProductSpec(); p.GpuName = txtName.Text; return(p); }
public int UpdateSingle(ProductSpec uSpec) { uSpec.Replace4MySQL(); StringBuilder stb = new StringBuilder("update product_spec"); stb.AppendFormat(" set spec_image='{0}'", uSpec.spec_image); stb.AppendFormat(" where spec_id = {0};", uSpec.spec_id); return _dbAccess.execCommand(stb.ToString()); }
public void SubWhereWithSpec() { var byProductId = new ProductSpec(1); var productQuery = new Query(nameof(Product)).Where(byProductId).Select("Id", "Name"); var query = Compile(productQuery); query[EngineCodes.SqlServer].Should().BeEquivalentTo("SELECT [Id], [Name] FROM [Product] WHERE ([Id] = 1)"); }
public string Update(ProductSpec uSpec) { uSpec.Replace4MySQL(); StringBuilder stb = new StringBuilder("update product_spec"); stb.AppendFormat(" set spec_name='{0}',spec_sort={1},spec_status={2},spec_image='{3}'", uSpec.spec_name, uSpec.spec_sort, uSpec.spec_status, uSpec.spec_image); stb.AppendFormat(" where spec_id = {0};", uSpec.spec_id); return stb.ToString(); }
public void CreateSpec() { var byProductId = new ProductSpec(1); var productQuery = new Query(nameof(Product)).Where(byProductId); var query = Compile(productQuery); query.Should().BeEquivalentTo("SELECT [id], [name] FROM [Product] WHERE [Id] = 1"); }
public ActionResult DeleteConfirmed(int id) { ProductSpec productspec = db.ProductSpecs.Find(id); db.ProductSpecs.Remove(productspec); db.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /ProductSpec/Edit/5 public ActionResult Edit(int id) { ProductSpec productspec = db.ProductSpecs.Find(id); ViewBag.ProductID = new SelectList(db.Product, "ProductID", "ProductName", productspec.ProductID); ViewBag.SpecificationID = new SelectList(db.Specification, "SpecificationID", "SpecName", productspec.SpecificationID); return(View(productspec)); }
public void test2() { ProductSpec productSpec = new ProductSpec { Name = "Coca" }; Assert.Throws <TestExamplesException>(() => productSpec.GetfilteredProducts(null)); }
public async Task <string> Handle(ProductSpecCreateCommand request, CancellationToken cancellationToken) { var spec = new ProductSpec(request.Name, request.Description, request.ProductId, identityService.GetOrganizationId(), identityService.GetUserId()); spec.UpdatePriceInfo(request.Price, request.PartnerPrice, request.PurchasePrice); await productSpecRepository.AddAsync(spec); return(spec.Id); }
public async Task Handle(ProductCreatedEvent notification, CancellationToken cancellationToken) { var spec = new ProductSpec(notification.Name, string.Empty, notification.Id, notification.OrganizationId, notification.Creator, notification.SourcedStaticMeshId); await productSpecRepository.AddAsync(spec); var product = await productRepository.FindAsync(notification.Id); product.SetDefaultProductSpec(spec); await productRepository.UpdateAsync(product); }
public string Update(ProductSpec specModel) { try { return _specDao.Update(specModel); } catch (Exception ex) { throw new Exception("ProductSpecMgr-->Update-->" + ex.Message, ex); } }
public ActionResult EditProductSpec(ProductSpec prou) { if (ProductSpecBLL.Edit(prou) > 0) { return(Content("edit_yes")); } else { return(Content("edit_no")); } }
public async Task <IActionResult> Create([Bind("ProductSpecId,ProductId,CategoryId,TagId,BrandId")] ProductSpec productSpec) { if (ModelState.IsValid) { _context.Add(productSpec); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(productSpec)); }
public async Task <IActionResult> Post([FromBody] ProductSpec value) { if (ModelState.IsValid == false) { return(BadRequest(ModelState)); } value = await repo.CreateAsync(AuthMan.GetAccountId(this), value); return(CreatedAtAction("Get", value)); }
public ActionResult Index() { ProductSpec productView = new ProductSpec(); productView.Categories = _context.Category.ToList(); productView.Brands = _context.Brand.ToList(); productView.Tags = _context.Tag.ToList(); productView.Products = _context.Products.ToList(); return(View(productView)); }
public ActionResult AddProductSpec(ProductSpec prou) { if (ProductSpecBLL.Add(prou) > 0) { return(Content("add_yes")); } else { return(Content("add_no")); } }
public int UpdateSingle(ProductSpec uSpec) { try { return _specDao.UpdateSingle(uSpec); } catch (Exception ex) { throw new Exception("ProductSpecMgr-->UpdateSingle-->" + ex.Message, ex); } }
public List<ProductSpec> Query(ProductSpec query) { try { return _specDao.Query(query); } catch (Exception ex) { throw new Exception("ProductSpecMgr-->Query(ProductSpec query)-->" + ex.Message, ex); } }
public async void Should_Return_Products_Count50_NameDesc() { var sp = new ProductSpecParams() { Sort = "nameDesc", PageSize = 50 }; var s = new ProductSpec(sp); var lst = await this._df.ProductRepo.GetListAsync(s); Assert.True(lst.Count == sp.PageSize); Assert.StartsWith("W", lst.First().Name); }
public IActionResult UpdateProductSpec(ProductSpec psP) { if (psP.Id == 0) { productSpecRepo.AddProductSpec(psP); } else { productSpecRepo.UpdateProductSpec(psP); } return(RedirectToAction(nameof(Index))); }
public ActionResult Edit(ProductSpec productspec) { if (ModelState.IsValid) { db.Entry(productspec).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductID = new SelectList(db.Product, "ProductID", "ProductName", productspec.ProductID); ViewBag.SpecificationID = new SelectList(db.Specification, "SpecificationID", "SpecName", productspec.SpecificationID); return(View(productspec)); }
public static ProductSpecificationDTO From(ProductSpec spec) { return(new ProductSpecificationDTO { Id = spec.Id, Name = spec.Name, Icon = spec.Icon, Description = spec.Description, Price = spec.Price, PartnerPrice = spec.PartnerPrice, PurchasePrice = spec.PurchasePrice }); }
public ActionResult Create(ProductSpec productspec) { if (ModelState.IsValid) { db.ProductSpecs.Add(productspec); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductID = new SelectList(db.Product, "ProductID", "ProductName", productspec.ProductID); ViewBag.SpecificationID = new SelectList(db.Specification, "SpecificationID", "SpecName", productspec.SpecificationID); return(View(productspec)); }
public async Task <IActionResult> Create([Bind("Value,ProductId,SpecificationId")] ProductSpec productSpec) { if (ModelState.IsValid) { _context.Add(productSpec); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", productSpec.ProductId); ViewData["SpecificationId"] = new SelectList(_context.Specification, "Id", "Name", productSpec.SpecificationId); return(View(productSpec)); }
public List<ProductSpec> Query(ProductSpec query) { StringBuilder stb = new StringBuilder("select spec_id,product_id,spec_type,spec_name,spec_sort,spec_status,spec_image from product_spec where 1=1 "); if (query.product_id != 0) { stb.AppendFormat(" and product_id = {0}", query.product_id); } if (query.spec_type != 0) { stb.AppendFormat(" and spec_type = {0}", query.spec_type); } return _dbAccess.getDataTableForObj<ProductSpec>(stb.ToString()); }
// GET: ProductSpecs/Create public IActionResult Create() { List <Product> products = _context.Products.ToList(); List <Category> categories = _context.Category.ToList(); List <Tag> tags = _context.Tag.ToList(); List <Brand> brands = _context.Brand.ToList(); ProductSpec productSpecs = new ProductSpec(); productSpecs.Products = products; productSpecs.Categories = categories; productSpecs.Tags = tags; productSpecs.Brands = brands; return(View(productSpecs)); }
public void test3() { var products = new List <Product>(); ProductSpec productSpec = new ProductSpec { Name = "Coca" }; var actual = productSpec.GetfilteredProducts(products); var expected = 0; Assert.Equal(expected, actual.Count); }
public void GetfilteredProducts_1() { var products = GetFakeProducts(); ProductSpec productSpec = new ProductSpec { Name = "Coca" }; var actual = productSpec.GetfilteredProducts(products); var expectedCount = 2; Assert.Equal(expectedCount, actual.Count); }
public string Insertproductspec(ProductSpec productspec) { try { db_1430683_co5027_productEntities db = new db_1430683_co5027_productEntities(); db.ProductSpecs.Add(productspec); db.SaveChanges(); return(productspec.GpuId + "was successfully inserted"); } catch (Exception e) { return("Error:" + e); } }
public async Task <IActionResult> Put([FromBody] ProductSpec value) { if (ModelState.IsValid == false) { return(BadRequest(ModelState)); } var res = await repo.UpdateAsync(AuthMan.GetAccountId(this), value); if (res == null) { return(NotFound()); } return(Ok(value)); }
public string SaveFromSpec(ProductSpec proSpec) { StringBuilder strSql = new StringBuilder(" insert into product_spec(spec_id,product_id,spec_type,spec_name,spec_image,spec_sort,spec_status) select {0},{1},"); strSql.AppendFormat(" spec_type,spec_name,spec_image,spec_sort,spec_status from product_spec where product_id={0}", proSpec.product_id); strSql.AppendFormat(" and spec_id={0};", proSpec.spec_id); return strSql.ToString(); }
public string QuerySpecPic() { BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];//獲取當前登入的供應商 string serverSpecPath = imgServerPath + specPath; string serverSpec100Path = imgServerPath + spec100Path; string serverSpec280Path = imgServerPath + spec280Path; _specTempMgr = new ProductSpecTempMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); string json = string.Empty; ProductSpecTemp psTemp = new ProductSpecTemp(); psTemp.Writer_Id = (int)vendorModel.vendor_id; psTemp.spec_type = 1; if (!string.IsNullOrEmpty(Request.Params["product_id"])) { psTemp.product_id = Request.Params["product_id"]; } uint pid = 0; if (uint.TryParse(Request.Params["product_id"], out pid)) { #region 正式表 ProductSpec pSpec = new ProductSpec(); pSpec.spec_type = 1; pSpec.product_id = Convert.ToUInt32(Request.Params["product_id"]); List<ProductSpec> spList = _specMgr.Query(pSpec); foreach (var item in spList) { if (item.spec_image != "") { item.spec_image = serverSpecPath + GetDetailFolder(item.spec_image) + item.spec_image; } else { item.spec_image = imgServerPath + "/product/nopic_50.jpg"; } } json = "{success:true,items:" + JsonConvert.SerializeObject(spList) + "}"; json = json.Replace("spec_image", "img"); #endregion } else { #region 供應商 臨時表 List<ProductSpecTemp> results = _specTempMgr.VendorQuery(psTemp); //JsonConvert.SerializeObject(); foreach (var item in results) { if (item.spec_image != "") { item.spec_image = serverSpecPath + GetDetailFolder(item.spec_image) + item.spec_image; } else { item.spec_image = imgServerPath + "/product/nopic_50.jpg"; } } json = "{success:true,items:" + JsonConvert.SerializeObject(results) + "}"; json = json.Replace("spec_image", "img"); #endregion } return json; }
public HttpResponseBase DeletePic() { string json = "{success:true,msg:\"" + Resources.VendorProduct.DELETE_SUCCESS + "\",path:\"" + default50Path + "\"}"; string deleteType = Request.Params["type"]; ProductSpecTemp psTemp = new ProductSpecTemp(); ProductSpec pSpec = new ProductSpec(); List<ProductSpecTemp> psList = new List<ProductSpecTemp>(); _specTempMgr = new ProductSpecTempMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];//獲取當前登入的供應商 string[] record = Request.Params["rec"].Split(','); if (record[0].Split('/').Length == defaultImgLength) //默认图片无法删除 { json = "{success:false,msg:\"" + Resources.VendorProduct.DEFAULT_CANNOT_DELETE + "\"}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } string fileName = record[0].Split('/')[imgNameIdx]; if (deleteType == "spec") { psTemp.spec_image = string.Empty; psTemp.spec_id = uint.Parse(record[1]); psTemp.spec_sort = uint.Parse(record[2]); psTemp.spec_status = uint.Parse(record[3]); pSpec.spec_image = string.Empty; pSpec.spec_id = uint.Parse(record[1]); pSpec.spec_sort = uint.Parse(record[2]); pSpec.spec_status = uint.Parse(record[3]); psList.Add(psTemp); string imageName = imgLocalPath + specPath + GetDetailFolder(fileName) + fileName; string image100 = imgLocalPath + spec100Path + GetDetailFolder(fileName) + fileName; string image280 = imgLocalPath + spec280Path + GetDetailFolder(fileName) + fileName; //刪除服務器上對應的圖片 DeletePicFile(imageName); DeletePicFile(image100); DeletePicFile(image280); } else if (deleteType == "desc") { string imageName = imgLocalPath + descPath + GetDetailFolder(fileName) + fileName; string imageName400 = imgLocalPath + desc400Path + GetDetailFolder(fileName) + fileName; DeletePicFile(imageName); DeletePicFile(imageName400); } psTemp.Writer_Id = (int)vendorModel.vendor_id; if (!string.IsNullOrEmpty(Request.Params["product_id"])) { psTemp.product_id = Request.Params["product_id"]; } //if (!string.IsNullOrEmpty(Request.Params["OldProductId"])) //{ // psTemp.product_id = Request.Params["OldProductId"]; //} try { _specTempMgr.Update(psList, "image"); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:\"" + Resources.VendorProduct.DELETE_SPEC_FAIL + "\"}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public string UpdateCopySpecId(ProductSpec proSpec) { return _specDao.UpdateCopySpecId(proSpec); }
public string UpdateCopySpecId(ProductSpec proSpec) { StringBuilder strSql = new StringBuilder(" set sql_safe_updates = 0;update product_spec set spec_id={0}"); strSql.AppendFormat(" where spec_id={0};set sql_safe_updates = 1;", proSpec.spec_id); return strSql.ToString(); }
public string SaveFromSpec(ProductSpec proSpec) { return _specDao.SaveFromSpec(proSpec); }
public HttpResponseBase DeletePic() { string json = "{success:true,msg:\"" + Resources.Product.DELETE_SUCCESS + "\",path:\"" + default50Path + "\"}"; try { string deleteType = Request.Params["type"]; int apporexplain = Convert.ToInt32(Request["apporexplain"]);//判斷是從前臺的APP傳來還是從explain傳來 ProductSpecTemp psTemp = new ProductSpecTemp(); ProductSpec pSpec = new ProductSpec(); List<ProductSpecTemp> psList = new List<ProductSpecTemp>(); List<ProductSpec> pspList = new List<ProductSpec>(); _specTempMgr = new ProductSpecTempMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); string[] records = Request.Params["rec"].Split('|'); foreach (var item in records) { string[] record = item.Split(','); if (record[0].Split('/').Length == defaultImgLength) //默认图片无法删除 { json = "{success:false,msg:\"" + Resources.Product.DEFAULT_CANNOT_DELETE + "\"}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } string fileName = record[0].Split('/')[imgNameIdx]; if (deleteType == "spec") { psTemp.spec_image = string.Empty; psTemp.spec_id = uint.Parse(record[1]); psTemp.spec_sort = uint.Parse(record[2]); psTemp.spec_status = uint.Parse(record[3]); pSpec.spec_image = string.Empty; pSpec.spec_id = uint.Parse(record[1]); pSpec.spec_sort = uint.Parse(record[2]); pSpec.spec_status = uint.Parse(record[3]); psList.Add(psTemp); pspList.Add(pSpec); string imageName = imgLocalPath + specPath + GetDetailFolder(fileName) + fileName; string image100 = imgLocalPath + spec100Path + GetDetailFolder(fileName) + fileName; string image280 = imgLocalPath + spec280Path + GetDetailFolder(fileName) + fileName; //刪除服務器上對應的圖片 DeletePicFile(imageName); DeletePicFile(image100); DeletePicFile(image280); } else if (deleteType == "desc") { SetPath(apporexplain); string imageName = imgLocalPath + descPath + GetDetailFolder(fileName) + fileName; string imageName400 = imgLocalPath + desc400Path + GetDetailFolder(fileName) + fileName; DeletePicFile(imageName); DeletePicFile(imageName400); } } //string[] record = Request.Params["rec"].Split(','); //if (record[0].Split('/').Length == defaultImgLength) //默认图片无法删除 //{ // json = "{success:false,msg:\"" + Resources.Product.DEFAULT_CANNOT_DELETE + "\"}"; // this.Response.Clear(); // this.Response.Write(json); // this.Response.End(); // return this.Response; //} //string fileName = record[0].Split('/')[imgNameIdx]; //if (deleteType == "spec") //{ // psTemp.spec_image = string.Empty; // psTemp.spec_id = uint.Parse(record[1]); // psTemp.spec_sort = uint.Parse(record[2]); // psTemp.spec_status = uint.Parse(record[3]); // pSpec.spec_image = string.Empty; // pSpec.spec_id = uint.Parse(record[1]); // pSpec.spec_sort = uint.Parse(record[2]); // pSpec.spec_status = uint.Parse(record[3]); // psList.Add(psTemp); // string imageName = imgLocalPath + specPath + GetDetailFolder(fileName) + fileName; // string image100 = imgLocalPath + spec100Path + GetDetailFolder(fileName) + fileName; // string image280 = imgLocalPath + spec280Path + GetDetailFolder(fileName) + fileName; // //刪除服務器上對應的圖片 // DeletePicFile(imageName); // DeletePicFile(image100); // DeletePicFile(image280); //} //else if (deleteType == "desc") //{ // //if (apporexplain == 1) // //{ // SetPath(apporexplain); // string imageName = imgLocalPath + descPath + GetDetailFolder(fileName) + fileName; // string imageName400 = imgLocalPath + desc400Path + GetDetailFolder(fileName) + fileName; // DeletePicFile(imageName); // DeletePicFile(imageName400); // //} // //else if(apporexplain == 2) // //{ // // string imageName = imgLocalPath + descMobilePath + GetDetailFolder(fileName) + fileName; // // string imageName400 = imgLocalPath + desc400MobilePath + GetDetailFolder(fileName) + fileName; // // DeletePicFile(imageName); // // DeletePicFile(imageName400); // //} //} if (string.IsNullOrEmpty(Request.Params["product_id"])) { psTemp.Writer_Id = (Session["caller"] as Caller).user_id; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { psTemp.product_id = Request.Form["OldProductId"]; } _specTempMgr.Update(psList, "image"); } else { uint productId = uint.Parse(Request.Params["product_id"]); foreach (var item in pspList) { item.product_id = productId; _specMgr.UpdateSingle(item); } //pSpec.product_id = uint.Parse(Request.Params["product_id"]); //_specMgr.UpdateSingle(pSpec); } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:true,msg:\"" + Resources.Product.DELETE_SPEC_FAIL + "\"}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase productPictrueTempSave() { string json = "{success:true}"; ProductTemp pTemp = new ProductTemp(); _productTempMgr = new ProductTempMgr(connectionString); _specTempMgr = new ProductSpecTempMgr(connectionString); _productPicMgr = new ProductPictureMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); if (string.IsNullOrEmpty(Request.Params["product_id"])) { if (!string.IsNullOrEmpty(Request.Params["image_InsertValue"])) pTemp.Product_Image = Request.Params["image_InsertValue"]; if (!string.IsNullOrEmpty(Request.Params["image_MobileValue"])) pTemp.Mobile_Image = Request.Params["image_MobileValue"];//如果手機說明圖有值,將值賦予Moibile_Image edit by wwei0216w 2015/3/18 if (!string.IsNullOrEmpty(Request.Params["productMedia"])) pTemp.product_media = Request.Params["productMedia"]; if (!string.IsNullOrEmpty(Request.Params["specify_Product_alt"])) pTemp.Product_alt = Request.Params["specify_Product_alt"];//add by wwei0216w 2015/4/9 pTemp.Writer_Id = (Session["caller"] as Caller).user_id; pTemp.Combo_Type = COMBO_TYPE; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; } ProductSpecTemp pSpec = new ProductSpecTemp(); List<ProductSpecTemp> pSpecList = new List<ProductSpecTemp>(); if (!string.IsNullOrEmpty(Request.Params["spec_InsertValue"])) { string[] Values = Request.Form["spec_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pSpec = new ProductSpecTemp(); pSpec.Writer_Id = (Session["caller"] as Caller).user_id; pSpec.product_id = pTemp.Product_Id; string[] perValue = Values[i].Split(','); if (!string.IsNullOrEmpty(perValue[0])) { pSpec.spec_image = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pSpec.spec_id = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pSpec.spec_sort = uint.Parse(perValue[2]); }; if (!string.IsNullOrEmpty(perValue[3])) { pSpec.spec_status = uint.Parse(perValue[3]); }; pSpecList.Add(pSpec); } } List<ProductPictureTemp> picList = new List<ProductPictureTemp>(); _pPicTempMgr = new ProductPictureTempImplMgr(connectionString); ProductPictureTemp pPic = new ProductPictureTemp(); if (!string.IsNullOrEmpty(Request.Params["picture_InsertValue"])) { string[] Values = Request.Form["picture_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pPic = new ProductPictureTemp(); string[] perValue = Values[i].Split(','); pPic.combo_type = COMBO_TYPE; pPic.writer_Id = (Session["caller"] as Caller).user_id; pPic.product_id = pTemp.Product_Id; if (!string.IsNullOrEmpty(perValue[0])) { pPic.image_filename = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pPic.image_sort = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pPic.image_state = uint.Parse(perValue[2]); }; picList.Add(pPic); } } //關於手機APP的代碼部份 List<ProductPictureTemp> picAppList = new List<ProductPictureTemp>(); //IProductPictureTempImplAppMgr ppt = new ProductPictureAppTempImplMgr(connectionString); ProductPictureTemp pa = new ProductPictureTemp(); if (!string.IsNullOrEmpty(Request.Params["mobilePic_InsertValue"])) { string[] Values = Request.Form["mobilePic_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pa = new ProductPictureTemp(); string[] AppValue = Values[i].Split(','); pa.combo_type = COMBO_TYPE; pa.writer_Id = (Session["caller"] as Caller).user_id; pa.product_id = pTemp.Product_Id; if (!string.IsNullOrEmpty(AppValue[0])) { pa.image_filename = AppValue[0]; }; if (!string.IsNullOrEmpty(AppValue[1])) { pa.image_sort = uint.Parse(AppValue[1]); }; if (!string.IsNullOrEmpty(AppValue[2])) { pa.image_state = uint.Parse(AppValue[2]); }; picAppList.Add(pa); } } try { int type = 1;//1:商品說明圖,2:手機App說明圖 int writer_id = (Session["caller"] as Caller).user_id; //保存至productTemp if (pTemp.Product_Image != "" || pTemp.product_media != "" || pTemp.Mobile_Image != "" || pTemp.Product_alt != "") { _productTempMgr.ProductTempUpdate(pTemp, "pic"); } //保存規格圖 _specTempMgr.Update(pSpecList, "image"); //保存說明圖 string oldProductId = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { oldProductId = Request.Form["OldProductId"]; } _pPicTempMgr.Save(picList, new ProductPictureTemp() { writer_Id = writer_id, combo_type = COMBO_TYPE, product_id = oldProductId }, type);// edit by wangwei0216w 註釋掉_pPicTempMgr.Save 以解決複製后不能讀取圖片路勁到數據庫 type = 2; _pPicTempMgr.Save(picAppList, new ProductPictureTemp() { writer_Id = writer_id, combo_type = COMBO_TYPE, product_id = oldProductId }, type); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:\"" + Resources.Product.EDIT_FAIL + "\"}"; } } else//更新正式表 { Product p = new Product(); uint productId = uint.Parse(Request.Params["product_id"]); if (!string.IsNullOrEmpty(Request.Params["image_InsertValue"])) p.Product_Image = Request.Params["image_InsertValue"];//如果商品說明圖有值,將值賦予Product_Image if (!string.IsNullOrEmpty(Request.Params["image_MobileValue"])) p.Mobile_Image = Request.Params["image_MobileValue"];//如果手機說明圖有值,將值賦予Moibile_Image edit by wwei0216w 2015/3/18 if (!string.IsNullOrEmpty(Request.Params["productMedia"])) p.product_media = Request.Params["productMedia"]; if (!string.IsNullOrEmpty(Request.Params["specify_Product_alt"])) p.Product_alt = Request.Params["specify_Product_alt"];//add by wwei0216w 2015/4/9 p.Product_Id = productId; _productMgr = new ProductMgr(connectionString); ProductSpec pSpec = new ProductSpec(); List<ProductSpec> pSpecList = new List<ProductSpec>(); if (!string.IsNullOrEmpty(Request.Params["spec_InsertValue"])) { string[] Values = Request.Form["spec_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pSpec = new ProductSpec(); pSpec.product_id = productId; string[] perValue = Values[i].Split(','); if (!string.IsNullOrEmpty(perValue[0])) { pSpec.spec_image = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pSpec.spec_id = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pSpec.spec_sort = uint.Parse(perValue[2]); }; if (!string.IsNullOrEmpty(perValue[3])) { pSpec.spec_status = uint.Parse(perValue[3]); }; pSpecList.Add(pSpec); } } List<ProductPicture> picList = new List<ProductPicture>(); _productPicMgr = new ProductPictureMgr(connectionString); ProductPicture pPic = new ProductPicture(); if (!string.IsNullOrEmpty(Request.Params["picture_InsertValue"])) { string[] Values = Request.Form["picture_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pPic = new ProductPicture(); string[] perValue = Values[i].Split(','); pPic.product_id = int.Parse(Request.Params["product_id"]); if (!string.IsNullOrEmpty(perValue[0])) { pPic.image_filename = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pPic.image_sort = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pPic.image_state = uint.Parse(perValue[2]); }; picList.Add(pPic); } } //手機app圖檔 List<ProductPicture> appList = new List<ProductPicture>(); _productPicMgr = new ProductPictureMgr(connectionString); ProductPicture apppPic = new ProductPicture(); if (!string.IsNullOrEmpty(Request.Params["mobilePic_InsertValue"])) { string[] Values = Request.Form["mobilePic_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { apppPic = new ProductPicture(); string[] perValue = Values[i].Split(','); apppPic.product_id = int.Parse(Request.Params["product_id"]); if (!string.IsNullOrEmpty(perValue[0])) { apppPic.image_filename = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { apppPic.image_sort = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { apppPic.image_state = uint.Parse(perValue[2]); }; appList.Add(apppPic); } } try { _productMgr.Update_Product_Spec_Picture(p, pSpecList, picList, appList); json = "{success:true,msg:\"" + Resources.Product.SAVE_SUCCESS + "\"}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:true,msg:\"" + Resources.Product.SAVE_FAIL + "\"}"; } } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase DeletePic() { string json = "{success:true,msg:\"" + Resources.Product.DELETE_SUCCESS + "\"}"; string deleteType = Request.Params["type"]; int apporexplain = Convert.ToInt32(Request["apporexplain"]);//判斷是從前臺的APP傳來還是從explain傳來 ProductSpecTemp psTemp = new ProductSpecTemp(); ProductSpec pSpec = new ProductSpec(); List<ProductSpecTemp> psList = new List<ProductSpecTemp>(); _specTempMgr = new ProductSpecTempMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); string[] record = Request.Params["rec"].Split(','); string fileName = record[0].Split('/')[imgNameIdx]; SetPath(apporexplain); if (deleteType == "desc") { string imageName = imgLocalPath + descPath + GetDetailFolder(fileName) + fileName; string imageName400 = imgLocalPath + desc400Path + GetDetailFolder(fileName) + fileName; DeletePicFile(imageName); DeletePicFile(imageName400); } if (string.IsNullOrEmpty(Request.Params["product_id"])) { psTemp.Writer_Id = (Session["caller"] as Caller).user_id; try { _specTempMgr.Update(psList, "image"); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:true,msg:\"" + Resources.Product.DELETE_SPEC_FAIL + "\"}"; } } else { pSpec.product_id = uint.Parse(Request.Params["product_id"]); try { _specMgr.UpdateSingle(pSpec); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:true,msg:\"" + Resources.Product.DELETE_SPEC_FAIL + "\"}"; } } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public string QuerySpecPic() { _specTempMgr = new ProductSpecTempMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); string json = string.Empty; if (string.IsNullOrEmpty(Request.Params["product_id"])) { //查找臨時表記錄 ProductSpecTemp psTemp = new ProductSpecTemp(); psTemp.Writer_Id = (Session["caller"] as Caller).user_id; psTemp.spec_type = 1; //string str = "{success:true,items:"+JsonConvert.+"}"; List<ProductSpecTemp> results = _specTempMgr.Query(psTemp); //JsonConvert.SerializeObject(); foreach (var item in results) { if (item.spec_image != "") { item.spec_image = imgServerPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image; } } json = "{success:true,items:" + JsonConvert.SerializeObject(results) + "}"; json = json.Replace("spec_image", "img"); } else { //查找正式表 ProductSpec pSpec = new ProductSpec(); pSpec.product_id = uint.Parse(Request.Params["product_id"]); pSpec.spec_type = 1; List<ProductSpec> spList = _specMgr.Query(pSpec); foreach (var item in spList) { if (item.spec_image != "") { item.spec_image = imgServerPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image; } } json = "{success:true,items:" + JsonConvert.SerializeObject(spList) + "}"; json = json.Replace("spec_image", "img"); } return json; }