public async Task <IActionResult> UpdateShopAttr(ShopAttrEntity entity) { if (ModelState.IsValid) { var data = await shopService.UpdateShopAttr(entity); return(Json(data)); } return(Json(ParrNoPass())); }
public async Task <BaseResult <bool> > AddShopAttr(ShopAttrEntity entity) { var count = shopAttrRepository.Count(c => c.shop_id.Equals(entity.shop_id)); if (count >= 1) { return(new BaseResult <bool>(3002, false)); } var isTrue = await shopAttrRepository.AddAsync(entity); if (!isTrue) { return(new BaseResult <bool>(201, false)); } return(new BaseResult <bool>(200, true)); }
public async Task <BaseResult <bool> > UpdateShopAttr(ShopAttrEntity entity) { //检查数据库中是否含有数据,如果含有,则修改,否则直接添加 var count = await shopAttrRepository.CountAsync(c => c.shop_id == entity.shop_id); var isTrue = false; if (count > 0) { isTrue = await shopAttrRepository.UpdateAsync(entity, true, false, c => c.shop_id); } else { isTrue = await shopAttrRepository.AddAsync(entity); } if (!isTrue) { return(new BaseResult <bool>(201, false)); } return(new BaseResult <bool>(200, true)); }