public void Update(TravelPlanDetail travelPlanDetail) { var _travelPlanDetail = GetByID(travelPlanDetail.Id); if (_travelPlanDetail != null) { _travelPlanDetailRepository.Update(travelPlanDetail); } else { throw new Exception("There is no travel plan detail"); } }
public void Add(TravelPlanDetail travelPlanDetail) { if (travelPlanDetail != null) { var travelPlan = GetTravelPlan(travelPlanDetail.TravelPlanId); if (travelPlan != null && travelPlan.AvailableSeatCount > travelPlanDetail.PurchasedSeat) { _travelPlanDetailRepository.Add(travelPlanDetail); travelPlan.AvailableSeatCount -= travelPlanDetail.PurchasedSeat; _travelPlanRepository.Update(travelPlan); } else { throw new Exception("There is no available seat"); } } else { throw new Exception("You should choose travel plan"); } }