public async Task <IActionResult> UpdateMealDishes([FromBody] AddMealDishesRequestDto request) { if (string.IsNullOrEmpty(request.DishesGuid)) { return(Failed(ErrorCode.Empty, "参数不正确")); } var verifyResult = VerifyDishes(request); if (verifyResult.Code != ErrorCode.Success) { return(verifyResult); } ; var dishesBiz = new MealDishesBiz(); var model = await dishesBiz.GetMealDishesModelById(request.HospitalGuid, request.DishesGuid); if (model is null) { return(Failed(ErrorCode.Empty, "菜品不存在")); } var existDishes = await dishesBiz.ExistDishesName(request.HospitalGuid, request.DishesName.Trim(), request.DishesGuid); if (existDishes) { return(Failed(ErrorCode.Empty, $"菜品“{request.DishesName}已存在”")); } model.DishesImg = request.DishesImg; model.DishesDescription = request.DishesDescription; model.DishesExternalPrice = request.DishesExternalPrice; model.DishesInternalPrice = request.DishesInternalPrice; model.DishesName = request.DishesName; model.LastUpdatedBy = UserID; model.LastUpdatedDate = DateTime.Now; var result = await dishesBiz.UpdateDish(model); return(result > 0 ? Success() : Failed(ErrorCode.DataBaseError, "菜品更新失败!")); }
public async Task <IActionResult> UpdateMealDishesStatus(string hospitalGuid, string dishesGuid) { if (string.IsNullOrEmpty(hospitalGuid) || string.IsNullOrEmpty(dishesGuid)) { return(Failed(ErrorCode.Empty, "参数不正确")); } var dishesBiz = new MealDishesBiz(); var model = await dishesBiz.GetMealDishesModelById(hospitalGuid, dishesGuid); if (model is null) { return(Failed(ErrorCode.Empty, "菜品不存在")); } model.DishesOnsale = model.DishesOnsale == 0 ? (sbyte)1 : (sbyte)0; var result = await dishesBiz.UpdateDish(model); return(result > 0 ? Success() : Failed(ErrorCode.DataBaseError, "菜品上下架失败!")); }