/// <summary> /// 列表 /// </summary> /// <param name="pn">分页下标</param> /// <returns></returns> public ActionResult List(GoodsVM vm, int pn = 1) { if (Session["QueryData"] != null && vm.RefreshFlag == 1) { vm = (GoodsVM)Session["QueryData"]; vm.RefreshFlag = 0; } else { Session["QueryData"] = vm; } int total = 0, pageIndex = pn, pageSize = PagingConfig.PAGE_SIZE; //分页查询 var list = _GoodsService.GetManagerList(vm.QueryName, vm.QueryBusinessmanName, pageIndex, pageSize, out total, int.Parse(Loginer.BusinessId)); var paging = new Paging <Goods>() { Items = list, Size = PagingConfig.PAGE_SIZE, Total = total, Index = pn, }; vm.Paging = paging; return(View(vm)); }
/// <summary> /// 编辑 /// </summary> /// <returns></returns> public ActionResult Edit(GoodsVM vm) { vm.Goods = _GoodsService.GetById(vm.Id) ?? new Goods(); vm.ImgInfo = vm.Goods.BaseImage ?? new BaseImage(); ///vm.Goods.Describes = StringToolsHelper.RemoveHtmlTag(vm.Goods.Describes); //获取菜品分类 //vm.GoodsCategoryList = _GoodsCategoryoService.GetAll().Where(p => p.BusinessInfoId == 0 || p.BusinessInfoId == vm.Goods.BusinessInfoId).ToList(); //获取餐厅列表 int tcount = 0; vm.BusinessList = _businessService.GetListByType((int)BusinessTypeEnum.衣, 1, 1000, out tcount); return(View(vm)); }
public ViewM() { if (OrdersVM == null) { GoodsVM = Files <GoodDTO> .Read("\\good.json"); StoragesVM = Files <StorageDTO> .Read("\\storage.json"); OrdersVM = Files <OrderDTO> .Read("\\order.json"); } SelectedStorage = StoragesVM.FirstOrDefault(); SelectedGood = GoodsVM.FirstOrDefault(); _customer = "Анонім"; }
public async Task <GoodsVM> GetGoodsAsync(string GoodsId) { var good = await GoodsService.GetGoodsAsync(GoodsId); var response = new GoodsVM() { Id = good.Id, GoodsName = good.GoodsName, GoodsType = good.GoodsType.GetCustomAttribute <EnumTextMetaAttribute>().Text, SellDescribe = good.SellDescribe, SellPrice = good.SellPrice, UserId = good.UserId, UserPhone = good.UserInfo.PhoneNumber }; return(response); }
public IActionResult Post(GoodsVM item) { try { // open a transacation // add goods object Goods obj = new Goods() { Name = item.Name, // 商品名稱 Price = item.Price, // 商品價格 Weight = item.Weight, // 商品重量 Amount = item.Amount, // 商品數量 Introduce = item.Introduce, // 商品內容 CategoriesID = item.CategoriesID, // 商品分類 CreateTime = DateTime.Now // 建立時間 }; _context.Goods.Add(obj); // add goodsdetail object foreach (var o in item.GoodsDetails) { GoodsDetail objDetaill = new GoodsDetail() { GoodsID = 0, // 商品ID CategoriesID = item.CategoriesID, // 商品分類ID ParamsID = o.ParamsID, // 參數ID Type = o.Type, // 動態參數or靜態屬性 Content = o.Content // 商品內容 }; _context.GoodsDetail.Add(objDetaill); } //_context.SaveChanges(); int ID = obj.ID; return(Ok()); } catch (Exception ex) { return(NotFound()); } }
public Goods() { InitializeComponent(); DataContext = new GoodsVM(); }