public async Task EditCommodity(Guid commodityId, string title, string content, Guid[] categoryIds, string mainImg, string tbUrl) { using (IDAL.ICommodityService commodityService = new DAL.CommodityService()) { var commodity = await commodityService.GetOneByIdAsync(commodityId); commodity.Title = title; commodity.Content = content; commodity.MainImage = mainImg; commodity.TaobaoUrl = tbUrl; await commodityService.EditAsync(commodity); using (IDAL.IComtoCategoryService comtoCategoryService = new DAL.ComtoCategoryService()) { //删除原有类别 foreach (var comtocateId in comtoCategoryService.GetAll(m => m.CommodityId == commodityId)) { await comtoCategoryService.RemoveAsync(comtocateId, false); } //保存现有类别 foreach (var categoryId in categoryIds) { await comtoCategoryService.CreateAsync(new ComtoCategory() { CategoryId = categoryId, CommodityId = commodityId }); } await comtoCategoryService.SaveAsync(); } } }
public async Task RemoveCommodity(Guid commodityId) { using (IDAL.ICommodityService commodityService = new DAL.CommodityService()) { var commodity = await commodityService.GetOneByIdAsync(commodityId); await commodityService.RemoveAsync(commodity); } }
public async Task BadCount(Guid commodityId) { using (IDAL.ICommodityService commodityService = new DAL.CommodityService()) { var commodity = await commodityService.GetOneByIdAsync(commodityId); commodity.BadCount++; await commodityService.EditAsync(commodity); } }