public void AddGoods(GoodsDTO goodsDTO, string creatorId) { var goodsImages = goodsDTO.GoodsImages.Select(item => new GoodsImage { CreatedOn = DateTime.Now, ImageId = item.ImageId }).ToList(); var grouponConditions = goodsDTO.GrouponConditions.Select(item => new GrouponCondition { MoreThanNumber = item.MoreThanNumber, Price = item.Price }).ToList(); var obj = GoodsFactory.CreateGoods( goodsDTO.ItemNumber, goodsDTO.Category, goodsDTO.SubCategory, goodsDTO.Title, goodsDTO.Description, goodsDTO.Detail, goodsDTO.UnitPrice, goodsDTO.MarketPrice, goodsDTO.Unit, goodsDTO.Stock, goodsDTO.StoreId, creatorId, goodsDTO.OptionalPropertyJsonObject, grouponConditions, goodsImages, goodsDTO.Address, goodsDTO.DistributionScope, goodsDTO.GoodsCategoryName, goodsDTO.VideoPath); _goodsRepository.Add(obj); goodsImages.ForEach(item => { _goodsImageRepository.Add(item); }); grouponConditions.ForEach(item => { _grouponConditionRepository.Add(item); }); _dbUnitOfWork.Commit(); }
public static int CreateGoods_s(IntPtr l) { int result; try { GoodsType goodsTypeId; LuaObject.checkEnum <GoodsType>(l, 1, out goodsTypeId); int contentId; LuaObject.checkType(l, 2, out contentId); int nums; LuaObject.checkType(l, 3, out nums); Goods o = GoodsFactory.CreateGoods(goodsTypeId, contentId, nums); LuaObject.pushValue(l, true); LuaObject.pushValue(l, o); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public override void Handle(CreateGoodsCommand command) { var newCustomer = goodsFactory.CreateGoods(command.Title, command.Length, command.Width, command.Weight, command.Description, command.NumberOfInventory); goodsRepository.Create(newCustomer); }