/// <summary> /// 添加店铺信息信息 /// </summary> /// <param name="inputDtos">要添加的店铺信息DTO信息</param> /// <returns>业务操作结果</returns> public OperationResult AddGoodsComments(params GoodsCommentInputDto[] inputDtos) { OperationResult result = GoodsCommentRepository.Insert(inputDtos, dto => { }, (dto, entity) => { if (dto.GoodsId.HasValue && dto.GoodsId.Value > 0) { Goods.Models.Goods goods = GoodsRepository.GetByKey(dto.GoodsId.Value); if (goods == null) { throw new Exception("商品不存在"); } goods.GoodsComments.Add(entity); entity.Goods = goods; } if (dto.UserId.HasValue && dto.UserId.Value > 0) { Identity.Models.User user = UserRepository.GetByKey(dto.UserId.Value); if (user == null) { throw new Exception("用户不存在"); } entity.User = user; } return(entity); }); return(result); }
private Transform ReturnOriginTransform(GoodsTable goodsTable) { GoodsRepository goodsRepository = new GoodsRepository(goodsTable); Transform goodsTransform = goodsRepository.FindGoods(MerchandiseInfo.MerchandiseEnum.RoomMaker).transform; return(goodsTransform); }
public static void ReadJson() { EnterJsonPath(); string myJsonString = File.ReadAllText(jsonPath); goodsRepository = JsonConvert.DeserializeObject <GoodsRepository>(myJsonString); }
public static void MainMenuOptions(Repository repositoryOption) { switch (repositoryOption) { case Repository.GoodsRepository: { using IGoodsRepository goodsRepository = new GoodsRepository(); var goodsRepositoryOperation = GoodsRepositoryMenu.ShowGoodsRepositoryMenu(); GoodsRepositoryMenu.ChooseOperationForGoodsRepository(goodsRepository, goodsRepositoryOperation); break; } case Repository.SuppliersRepository: { using ISuppliersRepository suppliersRepository = new SuppliersRepository(); var suppliersRepositoryOperation = SuppliersRepositoryMenu.ShowSuppliersRepositoryMenu(); SuppliersRepositoryMenu.ChooseOperatioForSuppliersRepository(suppliersRepository, suppliersRepositoryOperation); break; } case Repository.TypesOfGoodsRepository: { using ITypesOfGoodsRepository typesOfGoodsRepository = new TypesOfGoodsRepository(); var typesOgGoodsRepositoryOperation = TypesOfGoodsRepositoryMenu.ShowTypesOfGoodsRepositoryMenu(); TypesOfGoodsRepositoryMenu.ChooseOperationForTypesOfGoodsRepository(typesOfGoodsRepository, typesOgGoodsRepositoryOperation); break; } default: Environment.Exit(0); break; } }
public void Good_SaveAndRead() { GoodsManager gm = new GoodsManager(); Good good1 = new Good("A", 5, 2, 7); Tuple <bool, string> rtn = gm.AddNewGood(good1); Good good2 = new Good("B", 5, 2, 7); Tuple <bool, string> rtn2 = gm.AddNewGood(good2); string localPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string filename = Path.Combine(localPath, "Goods.json"); GoodsRepository repo = new GoodsRepository(); bool rtnSave = repo.SaveGoods(filename, gm.Goods); Assert.AreEqual(true, rtnSave); GoodsManager gm1 = new GoodsManager(); gm1.Goods = repo.ReadGoods(filename); Assert.AreEqual(2, gm1.GetNumberOfGoods()); Good g1 = gm1.SearchAGood("A"); Assert.AreEqual(good1.Item, g1.Item); Assert.AreEqual(good1.OfferItemNumber, g1.OfferItemNumber); Assert.AreEqual(good1.OfferPrice, g1.OfferPrice); Assert.AreEqual(good1.Price, g1.Price); }
public UnitOfWork(ShopContext _context) { context = _context; goods = new GoodsRepository(context); orders = new ShopOrderRepository(context); types = new TypeOfGoodsRepository(context); users = new UserRepository(context); }
public GoodsCommandHandler(GoodsRepository goodsRepository, CategoryRepository categoryRepository, GoodsCategoryRepository goodsCategoryRepository) { _goodsRepository = goodsRepository; _categoryRepository = categoryRepository; _goodsCategoryRepository = goodsCategoryRepository; }
/// <summary> /// 添加信息信息 /// </summary> /// <param name="inputDtos">要添加的店铺信息DTO信息</param> /// <returns>业务操作结果</returns> public async Task <OperationResult> AddCartGoodses(params CartGoodsInputDto[] inputDtos) { CartGoodsRepository.UnitOfWork.TransactionEnabled = true; List <string> names = new List <string>(); foreach (CartGoodsInputDto dto in inputDtos) { CartGoods cartGoods = dto.MapTo <CartGoods>(); if (dto.GoodsId.HasValue && dto.GoodsId.Value > 0) { Goods.Models.Goods goods = GoodsRepository.GetByKey(dto.GoodsId.Value); if (goods == null) { throw new Exception("商品不存在"); } cartGoods.Goods = goods; } if (dto.UserId.HasValue && dto.UserId.Value > 0) { User user = UserRepository.GetByKey(dto.UserId.Value); if (user == null) { throw new Exception("用户不存在"); } cartGoods.User = user; } if (dto.SkuId.HasValue && dto.SkuId.Value > 0) { Goods.Models.Sku sku = SkuRepository.GetByKey(dto.SkuId.Value); if (sku == null) { throw new Exception("Sku不存在"); } cartGoods.Sku = sku; } //判断商品的重复性,如果是相同商品相同规格只改变购物数量 CartGoods repeatCartGoods = CartGoodsRepository.Entities.SingleOrDefault(cg => cg.User.Id == dto.UserId.Value && cg.Goods.Id == dto.GoodsId.Value && cg.Sku.Id == dto.SkuId.Value); if (repeatCartGoods == null) { await CartGoodsRepository.InsertAsync(cartGoods); } else { repeatCartGoods.BuyCount += dto.BuyCount; await CartGoodsRepository.UpdateAsync(repeatCartGoods); } names.Add(cartGoods.Name); } return(await CartGoodsRepository.UnitOfWork.SaveChangesAsync() > 0 ? new OperationResult(OperationResultType.Success, $"“{names.ExpandAndToString()}”创建成功") : OperationResult.NoChanged); }
public void InstanceGoods(MerchandiseInfo.Merchandise merchandise) { GoodsRepository goodsRepository = new GoodsRepository(goodsTable); GameObject putGoods = _instancePrefab.InstanceGoods(merchandise, goodsRepository.FindGoods(merchandise.merchandise), sensorObj.transform.position); _menuButtonManager.InActivePutMerchandisePanel(); _moveGoods.MoveObjInit(putGoods); moveGoodsObj.SetActive(true); gameObject.SetActive(false); }
public DAO() { Log.Trace("DAO start creating."); Context = new StoreContext(); ClientRepository = new ClientRepository(Context); GoodsRepository = new GoodsRepository(Context); ManagerRepository = new ManagerRepository(Context); SaleRepository = new SaleRepository(Context); Log.Trace("DAO created."); }
/// <summary> /// 更新店铺信息信息 /// </summary> /// <param name="inputDtos">包含更新信息的店铺信息DTO信息</param> /// <returns>业务操作结果</returns> public OperationResult EditGoodss(params GoodsInputDto[] inputDtos) { return(GoodsRepository.Update(inputDtos, (dto, entity) => { }, (dto, entity) => { return entity; })); }
public static GoodsEntity GetGoodsEntityById(long cid) { GoodsEntity result = new GoodsEntity(); GoodsRepository mr = new GoodsRepository(); GoodsInfo info = mr.GetGoodsByKey(cid); if (info != null) { result = TranslateGoodsEntity(info); } return(result); }
public IEnumerable <GoodsTransition> FindByGoodsItemId(int goodsItemId) { var itemsRepository = new GoodsRepository(_context, _user); var item = itemsRepository.FindById(goodsItemId); if (item == null) { throw new ArgumentException("No goodsItem for that user"); } return(Transitions.Where(transition => transition.GoodsItemId == goodsItemId)); }
public static List <GoodsEntity> GetGoodsInfoPager(PagerInfo pager) { List <GoodsEntity> all = new List <GoodsEntity>(); GoodsRepository mr = new GoodsRepository(); List <GoodsInfo> miList = mr.GetAllGoodsInfoPager(pager); if (!miList.IsEmpty()) { foreach (GoodsInfo mInfo in miList) { GoodsEntity carEntity = TranslateGoodsEntity(mInfo); all.Add(carEntity); } } return(all); }
public static List <GoodsEntity> GetGoodsInfoByRule(string name, string mcode, int customerID, int status, PagerInfo pager) { List <GoodsEntity> all = new List <GoodsEntity>(); GoodsRepository mr = new GoodsRepository(); List <GoodsInfo> miList = mr.GetGoodsInfoByRule(name, mcode, customerID, status, pager); if (!miList.IsEmpty()) { foreach (GoodsInfo mInfo in miList) { GoodsEntity storeEntity = TranslateGoodsEntity(mInfo); all.Add(storeEntity); } } return(all); }
public static List <GoodsEntity> GetGoodsByRule(string goodsNo, int status, string goodsName = "", string goodsModel = "", string BarCode = "", int customerID = -1) { List <GoodsEntity> all = new List <GoodsEntity>(); GoodsRepository mr = new GoodsRepository(); List <GoodsInfo> miList = mr.GetGoodsByRule(goodsNo, status, goodsName, goodsModel, BarCode, customerID); if (!miList.IsEmpty()) { foreach (GoodsInfo mInfo in miList) { GoodsEntity StorageEntity = TranslateGoodsEntity(mInfo); all.Add(StorageEntity); } } return(all); }
public static int InsertImport(List <GoodsEntity> list, long operatorID) { GoodsRepository mr = new GoodsRepository(); int count = 0; if (list != null && list.Count > 0) { foreach (GoodsEntity entity in list) { count++; //检测是否存在 entity.CreateDate = DateTime.Now; entity.ChangeDate = DateTime.Now; entity.OperatorID = operatorID; entity.Status = 1; GoodsInfo info = GoodsService.TranslateGoodsInfo(entity); mr.CreateNew(info); } } return(count); }
public static bool ModifyGoods(GoodsEntity GoodsEntity) { int result = 0; if (GoodsEntity != null) { GoodsRepository mr = new GoodsRepository(); GoodsInfo goodsInfo = TranslateGoodsInfo(GoodsEntity); if (GoodsEntity.GoodsID > 0) { goodsInfo.ChangeDate = DateTime.Now; result = mr.ModifyGroup(goodsInfo); } else { goodsInfo.CreateDate = DateTime.Now; goodsInfo.ChangeDate = DateTime.Now; result = mr.CreateNew(goodsInfo); } } return(result > 0); }
public static void Main() { GoodsRepository goods = new GoodsRepository(); goods.Goods = new Good[] { new Good() { Name = "Test1", Count = 2, Price = 10 }, new Good() { Name = "Test2", Count = 3, Price = 15 }, new Good() { Name = "Test3", Count = 2, Price = 2 } }; WendingMachine machine = new WendingMachine(1000, goods); WendingMachine machine2 = new WendingMachine(1000, goods); WendingMachineGUI gui = new WendingMachineGUI(); gui.Machine = machine; while (true) { gui.Update(); } }
public AreasController(AreaRepository areaRepository, GoodsRepository goodsRepository) { _areaRepository = areaRepository; _estimator = new AreaUsedVolumeEstimate(goodsRepository); }
public static void RemoveGoods(string GoodsID) { GoodsRepository mr = new GoodsRepository(); mr.RemoveGoods(long.Parse(GoodsID)); }
/// <summary> /// 检查信息信息是否存在 /// </summary> /// <param name="predicate">检查谓语表达式</param> /// <param name="id">更新的信息编号</param> /// <returns>信息是否存在</returns> public bool CheckGoodsExists(Expression <Func <Models.Goods, bool> > predicate, int id = 0) { return(GoodsRepository.CheckExists(predicate, id)); }
public WendingMachine(int balance, GoodsRepository goods) { Balance = balance; _goods = goods; }
/// <summary> /// 添加店铺信息信息 /// </summary> /// <param name="inputDtos">要添加的店铺信息DTO信息</param> /// <returns>业务操作结果</returns> public async Task <OperationResult> AddGoodss(params GoodsInputDto[] inputDtos) { GoodsRepository.UnitOfWork.TransactionEnabled = true; List <string> names = new List <string>(); foreach (GoodsInputDto dto in inputDtos) { Models.Goods goods = new Models.Goods()//商品其他属性的绑定 { Name = dto.Name, GoodsPics = dto.GoodsPics, Description = dto.Description, Detail = dto.Detail, Price = dto.Price, Stock = dto.Stock, GoodsNumber = dto.GoodsNumber, BarCode = dto.BarCode, CreatedTime = DateTime.Now, BeginTime = DateTime.Now, IsGuarantee = dto.IsGuarantee, IsReceipt = dto.IsReceipt, IsSevenDayReplacement = dto.IsSevenDayReplacement, IsReplacement = dto.IsReplacement, IsCommend = dto.IsCommend, IsLocked = false }; //店铺 if (dto.ShopId.HasValue && dto.ShopId.Value > 0) { Shop.Models.Shop shop = await ShopRepository.GetByKeyAsync(dto.ShopId.Value); if (shop == null) { return(new OperationResult(OperationResultType.QueryNull, "店铺不存在")); } goods.Shop = shop; shop.Goodses.Add(goods); } //分类 if (dto.CategoryId.HasValue && dto.CategoryId.Value > 0) { Category category = await CategoryRepository.GetByKeyAsync(dto.CategoryId.Value); if (category == null) { return(new OperationResult(OperationResultType.QueryNull, "发布不存在")); } goods.Category = category; category.Goodses.Add(goods); } //运费模板 if (dto.ExpressTemplateId.HasValue && dto.ExpressTemplateId.Value > 0) { Shop.Models.ExpressTemplate expressTemplate = await ExpressTemplateRepository.GetByKeyAsync(dto.ExpressTemplateId.Value); if (expressTemplate == null) { return(new OperationResult(OperationResultType.QueryNull, "运费模板不存在")); } goods.ExpressTemplate = expressTemplate; } //商品属性 if (dto.GoodsAttrs.Count > 0) { foreach (Dtos.GoodsAttr goodsAttrDto in dto.GoodsAttrs) { //Hmh.Core.Shop.Models.SpecialExpressAddress specialExpressAddress = specialExpressAddressDto.MapTo<Hmh.Core.Shop.Models.SpecialExpressAddress>(); Models.GoodsAttr goodsAttr = new Models.GoodsAttr() { AttrName = goodsAttrDto.AttrName, AttrValue = goodsAttrDto.AttrValue }; await GoodsAttrRepository.InsertAsync(goodsAttr); goodsAttr.Goods = goods; goods.GoodsAttrs.Add(goodsAttr); } } //商品Sku if (dto.Skus.Count > 0) { foreach (Dtos.Sku skuDto in dto.Skus) { if (skuDto.Names.Count != skuDto.Values.Count) { return(new OperationResult(OperationResultType.Error, "规格名称和值不对应")); } Models.Sku sku = new Models.Sku() { Names = skuDto.Names.ExpandAndToString(), Values = skuDto.Values.ExpandAndToString(), Price = skuDto.Price, Stock = skuDto.Stock, GoodsNumber = skuDto.GoodsNumber, BarCode = skuDto.BarCode, SkuPic = skuDto.SkuPic }; await SkuRepository.InsertAsync(sku); sku.Goods = goods; goods.Skus.Add(sku); } } int id = await GoodsRepository.InsertAsync(goods); //if (!(id > 0)) // return new OperationResult(OperationResultType.Error, "添加失败"); names.Add(goods.Name); } return(await GoodsRepository.UnitOfWork.SaveChangesAsync() > 0 ? new OperationResult(OperationResultType.Success, $"商品“{names.ExpandAndToString()}”创建成功") : OperationResult.NoChanged); }
public AreaUsedVolumeEstimate(GoodsRepository goodsRepository) { _goodsRepository = goodsRepository; }
public GoodsController(GoodsRepository repository) { _repository = repository; }
/// <summary> /// 添加信息信息 /// </summary> /// <param name="inputDtos">要添加的店铺信息DTO信息</param> /// <returns>业务操作结果</returns> public async Task <OperationResult> AddOrders(params OrderInputDto[] inputDtos) { //开启事务 OrderRepository.UnitOfWork.TransactionEnabled = true; List <string> names = new List <string>(); foreach (OrderInputDto dto in inputDtos) { //auto mapper maybe fileter 不能通过自动映射 数据集合也会映射 //Models.Order order = dto.MapTo<Models.Order>(); Models.Order order = new Models.Order() { ShopName = dto.ShopName, OrderNumber = dto.OrderNumber, Amount = dto.Amount, HPayAmount = dto.HPayAmount, RealAmount = dto.RealAmount, Preferential = dto.Preferential, ExpressFee = dto.ExpressFee, Remark = dto.Remark, State = dto.State }; //店铺 if (dto.ShopId.HasValue && dto.ShopId.Value > 0) { Shop.Models.Shop shop = await ShopRepository.GetByKeyAsync(dto.ShopId.Value); if (shop == null) { return(new OperationResult(OperationResultType.QueryNull, "店铺不存在")); } order.Shop = shop; shop.Orders.Add(order); } //用户 if (dto.UserId.HasValue && dto.UserId.Value > 0) { User user = await UserRepository.GetByKeyAsync(dto.UserId.Value); if (user == null) { return(new OperationResult(OperationResultType.QueryNull, "用户不存在")); } order.User = user; user.Orders.Add(order); } //配送信息 order.OrderExpress = new OrderExpress() { Name = dto.OrderExpress.Name, Region = dto.OrderExpress.Region, DetailAddress = dto.OrderExpress.DetailAddress, Zip = dto.OrderExpress.Zip, Mobile = dto.OrderExpress.Mobile }; //商品 if (dto.OrderGoodses.Count > 0) { foreach (OrderGoodsInputDto orderGoodsDto in dto.OrderGoodses) { //auto mapper maybe filter OrderGoods orderGoods = orderGoodsDto.MapTo <OrderGoods>(); //处理商品 if (orderGoodsDto.GoodsId.HasValue && orderGoodsDto.GoodsId.Value > 0) { Goods.Models.Goods goods = await GoodsRepository.GetByKeyAsync(orderGoodsDto.GoodsId.Value); if (goods == null) { throw new Exception("商品不存在"); } orderGoods.Goods = goods; } await OrderGoodsRepository.InsertAsync(orderGoods); orderGoods.Order = order; order.OrderGoodses.Add(orderGoods); } } int id = await OrderRepository.InsertAsync(order); names.Add(order.OrderNumber); } return(await OrderRepository.UnitOfWork.SaveChangesAsync() > 0 ? new OperationResult(OperationResultType.Success, $"订单“{names.ExpandAndToString()}”创建成功") : OperationResult.NoChanged); }
/// <summary> /// 删除店铺信息信息 /// </summary> /// <param name="ids">要删除的店铺信息编号</param> /// <returns>业务操作结果</returns> public OperationResult DeleteGoodss(params int[] ids) { return(GoodsRepository.Delete(ids)); }
public BasketCommandHandler(BasketRepository basketRepository, ShopContext context, GoodsRepository goodsRepository) { _basketRepository = basketRepository; _context = context; _goodsRepository = goodsRepository; }
public async Task <ActionResult> AddDo() { IContractTypeRepository _repo = new ContractTypeRepository(); Response result = await _repo.GetallContractTrypes(); List <ContractTypeVM> list = ((IEnumerable)result.Value).Cast <ContractTypeVM>().ToList(); var selectListItems = list.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Type }).ToList(); ViewBag.LstContractType = selectListItems; ICityRepository _repocity = new CityRepository(); Response resultcity = await _repocity.GetALLCities(); List <CityVM> listcity = ((IEnumerable)resultcity.Value).Cast <CityVM>().ToList(); var selectListItemscity = listcity.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.City1 }).ToList(); ViewBag.LstCities = selectListItemscity; IPartyRepository _repoparty = new PartyRepository(); Response resultparty = await _repoparty.GetALLParties(); List <PartyVM> listparty = ((IEnumerable)resultparty.Value).Cast <PartyVM>().ToList(); var selectListItemsparty = listparty.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Party1 }).ToList(); ViewBag.LstParty = selectListItemsparty; IGoodsRepository _repogoods = new GoodsRepository(); Response resultgoods = await _repogoods.GetALLGoods(); List <GoodsTypeVM> listgoods = ((IEnumerable)resultgoods.Value).Cast <GoodsTypeVM>().ToList(); var selectListItemsgoods = listgoods.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Goods }).ToList(); ViewBag.LstGoods = selectListItemsgoods; Response resultUnits = _repogoods.GetallUnits(); List <DropDownListModel> listunits = ((IEnumerable)resultUnits.Value).Cast <DropDownListModel>().ToList(); var selectListUnits = listunits.Select(x => new SelectListItem() { Value = x.Value.ToString(), Text = x.Text }).ToList(); ViewBag.LstUnits = selectListUnits; ISettingRepository _setting = new SettingRepository(); DorderVM Do = new DorderVM(); bool autoInc = _setting.GetDoAutoIncrement(); if (autoInc) { Do.DoNumber = (_setting.GetLastDoNumber() + 1); } else { Do.DoNumber = _setting.GetLastDoNumber(); } Do.ContractNumber = _setting.GetLastContractNumber(); ViewBag.isAutoIncrement = autoInc; Do.BagsPerWeight = _setting.GetPackPerWeight(); return(View(Do)); }