public GameStoreViewModel(IDispatcherService dispatcherService, string functionTag, IDialogService dialogService, ScoreInfoService scoreInfoService, GoodsService goodsService) : base(dispatcherService, functionTag) { _dialogService = dialogService; _scoreInfoService = scoreInfoService; _goodsService = goodsService; DataGridItemChanged = new RelayCommand <DataGridItemChangedEventArgs>(OnDataGridItemChanged); RefreshList = new RelayCommand(PrivateRefreshList); RemoveItem = new RelayCommand(() => { if (_dialogService.ShowOKCancel("确定删除选中数据吗?")) { _ = _goodsService.RemoveAsync(SelectedItem); GoodsItems.Remove(SelectedItem); } }, () => { return(SelectedItem != null); }); RemoveAll = new RelayCommand(() => { if (_dialogService.ShowOKCancel("确定删除所有数据吗?")) { _ = _goodsService.RemoveAllAsync(); GoodsItems = null; } }, () => { return(GoodsItems != null); }); AddData = new RelayCommand(() => { if (string.IsNullOrEmpty(BuyCmd)) { _dialogService.ShowInformation("购买命令不能为空"); return; } if (GoodsItems.FirstOrDefault(p => p.BuyCmd == BuyCmd) != null) { _dialogService.ShowInformation("购买命令重复"); return; } var dto = new GoodsDto() { GoodsName = GoodsName, BuyCmd = BuyCmd, Content = Content, Amount = Amount, Quality = Quality, Price = Price, GoodsType = GoodsType }; _ = _goodsService.AddAsync(dto); GoodsItems.Add(dto); }); AddAvailableVariables(); PrivateRefreshList(); }
public ActionResult Add(GoodsDto goods) { ResultJsonInfo resultJsonInfo = new ResultJsonInfo() { Data = "", ErrorMsg = "", Success = true }; if (goods != null) { if (Service.FindByGoodsName(goods.GoodsName) == null) { goods.CreateUser = ServiceHelper.GetCurrentUser().UserName; goods.CredateTime = DateTime.Now; if (!Service.Add(goods)) { resultJsonInfo.Success = false; resultJsonInfo.ErrorMsg = "添加失敗"; return(Content("<script>alert('添加失敗');history.go(-1);</script>")); } } else { return(Content("<script>alert('该商品已存在');history.go(-1);</script>")); } } return(Content("<script>alert('添加成功');</script>")); //return this.Ajax_JGCloseAndMessage("保存成功"); }
public OperationResult Edit(GoodsDto model) { if (model == null) { return(new OperationResult(OperationResultType.Error, "不能修改空记录!")); } Goods goods = this._goodsRepository.GetByKey(model.Id); if (goods != null) { try { goods.Name = model.Name; goods.Spec = model.Spec; goods.Decription = model.Decription; this._goodsRepository.Update(goods); return(new OperationResult(OperationResultType.Success, "成功修改记录!")); } catch (Exception e) { return(new OperationResult(OperationResultType.Error, "修改记录失败!", e)); } } return(new OperationResult(OperationResultType.Error, "找不到将要修改的记录!")); }
public IActionResult PostGoods([FromBody] GoodsDto model) { try { var Goods = new Goods() { SysUserId = model.SysUserId, GoodsKindId = model.GoodsKindId, NewPrice = model.NewPrice, OldPrice = model.OldPrice, Notice = model.Notice, Name = model.Name, Img = model.Img, CreatDate = DateTime.Now, Comment1 = "上架", Comment2 = model.Comment2 }; _context.Goodss.Add(Goods); _context.SaveChanges(); return(Ok("添加成功")); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
public static GoodsDto ToDto(this Goods model) { var dto = new GoodsDto { ID = model.ID, DeliveryItemID = model.DeliveryItemID, SaleID = model.SaleID, Sale = model.Sale?.ToDto(), IsSold = model.IsSold, Price = model.Price, RecommendedPrice = model.DeliveryItem?.Article?.RecommendedPrice, //ClientID = model.ClientID,TODO //SalePrice = model.SalePrice, //SaleDate = model.SaleDate, //SoldBy = model.SoldBy, //SaleLocationID = model.SaleLocationID, DeliveryItem = model.DeliveryItem?.ToDto(), //Client = model.Client?.ToDto(), //SoldByUser = model.SoldByUser?.Login, //SaleLocation = model.SaleLocation?.ToDto(), Storages = model.Storages?.OrderByDescending(s => s.FromDate).Select(s => s.ToDto()).ToList(), Quantity = 1 }; dto.MapDetails(model); dto.CanBeDeleted = false; return(dto); }
public GoodsDto GetGoods(string goodsSKU) { var sql = string.Format(@" select a.Name, b.Sku, b.Description, b.Price from shangpin a left join shangjia_sku_info b on a.Id=b.ShangPinId where Sku='{0}' ", goodsSKU); var skuArr = goodsSKU.Split('-'); var db = Common.DbFactory.CreateDbSession(); var sqlColor = string.Format("select * from yanse where id='{0}'", skuArr[3]); var colorDt = db.Context.QueryTable(sqlColor); /*颜色*/ var color = colorDt.ToList <GoodsColorDto>()[0]; var sqlSize = string.Format("select * from chima where id='{0}'", skuArr[4]); /*尺寸*/ var sizeDt = db.Context.QueryTable(sqlSize); var size = sizeDt.ToList <GoodsSizeDto>()[0]; /*门店和经销商*/ var sqlMendian = string.Format(@"select a.Id, a.JingXiaoShangId, a.Name as MenDianName, b.name as JingXiaoShang from mendian a left join jingxiaoshang b on a.JingXiaoShangId=b.Id where a.Id='{0}'", skuArr[0]); var mendianDt = db.Context.QueryTable(sqlMendian); var mendian = mendianDt.ToList <GoodsDto>()[0]; var dt = db.Context.QueryTable(sql); var o1 = dt.ToList <GoodsDto>()[0]; var o = new GoodsDto() { JingXiaoShang = mendian.JingXiaoShang, MenDianName = mendian.MenDianName, DiapalyPrice = "¥" + o1.Price, SKU = goodsSKU, Price = o1.Price, Id = o1.Id, Description = o1.Description, //"TZ.mall 2014 男装修身 格子 条纹 加绒 加厚 免烫保暖长袖衬衫 男 MS01藏青色 L", Brand = o1.DiapalyPrice, //"TZ.mall", DonationDesc = o1.DonationDesc, //"TZ.mall 秋冬保暖纯棉袜子 秋冬保暖必需品 赠品拍下不发货 随机发放颜色 袜子 均码X 1", PrGoodsSKU = skuArr[0] + "-" + skuArr[1] + "-" + skuArr[2], //sku前缀 Color = color.Name, ColorId = color.Id, Size = size.Name, SizeId = size.Id, Ecoupons = "" }; o.IsDispalyDonationDesc = string.IsNullOrEmpty(o.DonationDesc) ? "none" : "block"; o.IsDispalyEcoupons = string.IsNullOrEmpty(o.Ecoupons) ? "none" : "block"; return(o); }
/// <summary> /// The from goods dto to goods. /// </summary> /// <param name="goodsDto"> /// The goods dto. /// </param> /// <returns> /// The <see cref="Goods"/>. /// </returns> public static Goods FromGoodsDtoToGoods(GoodsDto goodsDto) { Mapper.Reset(); Mapper.Initialize(cfg => cfg.CreateMap <GoodsDto, Goods>() .ForMember("ProviderId", map => map.MapFrom(g => g.Provider.ProviderId)) .ForMember("GoodsCategoryId", map => map.MapFrom(g => g.GoodsCategory.GoodsCategoryId)) .ForMember("GoodsClassId", map => map.MapFrom(g => g.GoodsClass.GoodsClassId))); return(Mapper.Map <GoodsDto, Goods>(goodsDto)); }
public void UpdateGoods(GoodsDto dto) { goodsRepository.Save(x => x.Id == dto.Id, x => new Goods { GoodsName = dto.GoodsName, Size = dto.Size, Quantity = Convert.ToInt32(dto.Quantity), Integral = Convert.ToInt32(dto.Integral) }); }
public async Task <IHttpActionResult> PostGoods(GoodsDto dto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _goodsService.CreateGoods(dto); return(Ok(result)); }
private void Additem2() { List <GoodsDataDto> data = new List <GoodsDataDto>(); int index = UnityEngine.Random.Range(2, 4); GoodsDto goodsDto = GoodsDataManage.dataDic[index.ToString()]; GoodsDataDto goodsDataDto = new GoodsDataDto(goodsDto.id, goodsDto.name, 1, goodsDto.describe, goodsDto.tag, goodsDto.isAdd); dataList.Add(goodsDataDto); data.Add(goodsDataDto); scrollViewManage.LoadData(data); }
public IActionResult EditGoods([FromBody] GoodsDto model) { try { var GoodsInfo = _context.Goodss.Where(x => x.GoodsId == model.GoodsId).FirstOrDefault(); return(Ok(GoodsInfo)); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
public IHttpActionResult PuteDGoods(GoodsDto model) { OperationResult result = this._goodsService.Delete(model); if (result.ResultType == OperationResultType.Success) { return(CreatedAtRoute("defaultApi", new { id = model.Id }, model)); } else { return(BadRequest(ModelState)); } }
public IHttpActionResult PostGoods(GoodsDto model) { OperationResult result = this._goodsService.Add(model); if (result.ResultType == OperationResultType.Success) { GoodsDto _goods = (GoodsDto)result.AppendData; return(CreatedAtRoute("DefaultApi", new { id = _goods.Id }, _goods)); } else { return(BadRequest(ModelState)); } }
public void GoodsDomainTransformerTest() { var goodsDto = new GoodsDto( 1, "title1", new ProviderDto(123, string.Empty, string.Empty, string.Empty), new GoodsCategoryDto(456, string.Empty), new GoodsClassDto(789, string.Empty), 100m); var expectedDomain = new Goods(1, "title1", 123, 456, 789, 100m); var result = GoodsTransformer.FromGoodsDtoToGoods(goodsDto); Assert.AreEqual(expectedDomain.GoodsClassId, result.GoodsClassId); }
public JsonResult UpSetGoods(GoodsDto Goods) { return(ExceptionCatch.Invoke(() => { if (Goods.Id > 0) { GoodsService.Instance.UpdateGoods(Goods); } else { GoodsService.Instance.AddGoods(Goods); } })); }
public GoodsDto GetGoods(string goodsSKU) { var o = new GoodsDto() { DiapalyPrice = "¥3699.00", Price = 3699, Id = 1, Desc = "TZ.mall 2014 男装修身 格子 条纹 加绒 加厚 免烫保暖长袖衬衫 男 MS01藏青色 L", Brand = "TZ.mall", DonationDesc = "TZ.mall 秋冬保暖纯棉袜子 秋冬保暖必需品 赠品拍下不发货 随机发放颜色 袜子 均码 X 1", Ecoupons = "" }; o.IsDispalyDonationDesc = string.IsNullOrEmpty(o.DonationDesc) ? "none" : "block"; o.IsDispalyEcoupons = string.IsNullOrEmpty(o.Ecoupons) ? "none" : "block"; return(o); }
public JsonResult Edit(GoodsDto goods) { ResultJsonInfo resultJsonInfo = new ResultJsonInfo() { Data = "", ErrorMsg = "", Success = true }; if (goods != null) { goods.UpdateUser = ServiceHelper.GetCurrentUser().UserName; goods.UpdateTime = DateTime.Now; if (!Service.Update(goods)) { resultJsonInfo.Success = false; resultJsonInfo.ErrorMsg = "更新失敗"; } } return(Json(new { resultJsonInfo }, JsonRequestBehavior.AllowGet)); }
public GoodsDto Get() { GoodsEntity goodsEntity = new GoodsEntity() { Name = "apple", Price = 22, Id = 6, CreateTime = DateTime.Now }; // 属性很多,赋值麻烦 // 修改业务逻辑 GoodsDto goodsDto = new GoodsDto() { GoodsName = goodsEntity.Name, Price = goodsEntity.Price, }; return(goodsDto); }
public IActionResult GetUserGoods(GoodsDto model) { //var TotalCount = _context.Goodss.Where(x => x.SysUserId == model.SysUserId && x.GoodsKindId == model.GoodsKindId).Count(); var UserGoods = (from a in _context.Goodss where a.SysUserId == model.SysUserId && a.GoodsKindId == model.GoodsKindId && a.Comment1 == "上架" select new GoodsDto() { GoodsId = a.GoodsId, Name = a.Name, Img = a.Img, Notice = a.Notice, NewPrice = a.NewPrice, OldPrice = a.OldPrice, GoodsKindId = a.GoodsKindId, }); //.OrderBy(d => d.GoodsId).Skip(model.searchPageNum).Take(model.callbackcount).AsNoTracking().ToList(); UserGoods.ToList(); return(Ok(UserGoods)); }
public OperationResult Add(GoodsDto model) { if (model == null) { return(new OperationResult(OperationResultType.Error, "不能添加空记录!", null)); } Goods goods = new Goods { Id = model.Id, Name = model.Name, Spec = model.Spec, Decription = model.Decription }; try { this._goodsRepository.Add(goods); return(new OperationResult(OperationResultType.Success, "添加成功!", new GoodsDto { Id = goods.Id, Name = goods.Name, Spec = goods.Spec, Decription = goods.Decription })); } catch (Exception e) { return(new OperationResult(OperationResultType.Error, "添加保存失败!", e)); } }
public IActionResult Modify([FromBody] GoodsDto model) { try { var GoodInfo = _context.Goodss.Where(x => x.GoodsId == model.GoodsId).FirstOrDefault(); GoodInfo.Name = model.Name; GoodInfo.GoodsKindId = model.GoodsKindId; GoodInfo.NewPrice = model.NewPrice; GoodInfo.OldPrice = model.OldPrice; GoodInfo.Notice = model.Notice; GoodInfo.Img = model.Img; GoodInfo.UpDate = DateTime.Now; GoodInfo.Comment1 = model.Comment1; GoodInfo.Comment2 = model.Comment2; _context.SaveChanges(); return(Ok("修改成功")); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
public OperationResult Delete(GoodsDto model) { if (model == null) { return(new OperationResult(OperationResultType.Error, "不能删除空记录!")); } Goods goods = this._goodsRepository.GetByKey(model.Id); if (goods != null) { try { goods.IsDeleted = true; this._goodsRepository.Update(goods); return(new OperationResult(OperationResultType.Success, "成功删除记录!")); } catch (Exception e) { return(new OperationResult(OperationResultType.Error, "删除记录失败!", e)); } } return(new OperationResult(OperationResultType.Error, "找不到将要删除的记录!")); }
/// <summary> /// 进入盘点详情事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void onEnterInventoryDetailLocal(object sender, RoutedEventArgs e) { Button btnItem = sender as Button; int id; if (btnItem.Name == "LocalInventoryBtn") { //SetPopInventoryEvent(this, true); LoadingDataEvent(this, true); #if TESTENV HashSet <CommodityEps> hs = RfidHelper.GetEpcDataJsonInventory(out bool isGetSuccess); #else HashSet <CommodityEps> hs = RfidHelper.GetEpcDataJson(out bool isGetSuccess); #endif LoadingDataEvent(this, false); //SetPopInventoryEvent(this, false); if (hs.Count == 0) { MessageBox.Show("医疗柜中没有任何商品!", "温馨提示", MessageBoxButton.OK); } else { BaseData <CommodityCode> bdCommodityCode = CommodityCodeBll.GetInstance().GetCommodityCode(hs); HttpHelper.GetInstance().ResultCheck(bdCommodityCode, out bool isSuccess); CommodityCodeBll.GetInstance().GetExpirationAndManufactor(bdCommodityCode, out bool isSuccess2); if (!isSuccess) { MessageBox.Show("盘点时获取商品信息失败!", "温馨提示", MessageBoxButton.OK); } else { List <GoodsDto> list = new List <GoodsDto>(); foreach (var item in bdCommodityCode.body.objects) { GoodsDto goodItem = new GoodsDto { name = item.CommodityName, code = item.name, position = item.GoodsLocationName }; if (isSuccess2) { goodItem.Specifications = item.Specifications; if (item.ManufactorName != null) { goodItem.ManufactorName = item.ManufactorName; } if (item.ExpirationDate != null) { goodItem.ExpirationDate = item.ExpirationDate; } } list.Add(goodItem); } id = inventoryBll.NewInventory(list, InventoryType.Manual); GetInventoryList(); EnterInventoryDetailLocalEvent(this, id); } } } else { id = (int)btnItem.CommandParameter; EnterInventoryDetailLocalEvent(this, id); } }
public void UpdateGoods(GoodsDto goods) { throw new NotImplementedException(); }
public void AddGoodsOfProvider(GoodsDto goods) { throw new NotImplementedException(); }
public virtual void Updategoods(GoodsDto goods) { Domain.Goods model = AutoMapper.Mapper.Map <Domain.Goods>(goods); _GoodsRepository.Update(model); }
public virtual void Addgoods(GoodsDto goods) { Domain.Goods model = AutoMapper.Mapper.Map <Domain.Goods>(goods); _GoodsRepository.Insert(model); }
public void UpdateGoodsImage(GoodsDto dto) { goodsRepository.Save(x => x.Id == dto.Id, x => new Goods { GoodsImage = dto.GoodsImage }); }
public static Goods ToEntity(this GoodsDto dto) { return(new Goods { }); }
public void AddGoods(GoodsDto dto) { var entity = dto.ToModel <Goods>(); goodsRepository.Insert(entity); }