public async Task <IBusinessResultValue <PromotionReviewStatusEnum> > ProceedMemberPromotionAsync(PromotionReviewStatusEnum currentStep, PromotionReviewStatusEnum nextStep, int branchId) { var result = new BusinessResultValue <PromotionReviewStatusEnum>(); try { var entity = await unitOfWork.BranchPromotionDataService.GetQuery() .IncludeFilter(x => x.MemberPromotions.Where(y => y.Deleted == false)) .IncludeFilter(x => x.MemberPromotions.Select(y => y.Details.Where(c => c.Deleted == false))) .FirstOrDefaultAsync(x => x.BranchId == branchId && x.PromotionReviewStatusId == currentStep); if (entity != null) { var salesAssigned = entity.MemberPromotions.Sum(x => x.Details.Sum(c => (decimal?)c.SupplierPromotion)) ?? 0; var receiptAssigned = entity.MemberPromotions.Sum(x => x.Details.Sum(c => (decimal?)c.ReceiptPromotion)) ?? 0; var compensatoryAssigned = entity.MemberPromotions.Sum(x => x.Details.Sum(c => (decimal?)c.CompensatoryPromotion)) ?? 0; if (salesAssigned > entity.SupplierPromotion) { result.ReturnMessage.Add("جمع مبلغ پورسانت تامین کننده پرسنل از پورسانت فروش تامین کنندگان مرکز بیشتر میباشد"); result.ReturnStatus = false; } if (receiptAssigned > entity.PrivateReceiptPromotion + entity.TotalReceiptPromotion) { result.ReturnMessage.Add("جمع مبلغ پورسانت وصول پرسنل از پورسانت وصول مرکز بیشتر میباشد"); result.ReturnStatus = false; } if (compensatoryAssigned > entity.CompensatoryPromotion) { result.ReturnMessage.Add("جمع مبلغ پورسانت ترمیمی پرسنل از پورسانت ترمیمی مرکز بیشتر میباشد"); result.ReturnStatus = false; } if (result.ReturnStatus) { entity.PromotionReviewStatusId = nextStep; result.ResultValue = nextStep; unitOfWork.BranchPromotionDataService.Update(entity); await unitOfWork.CommitAsync(); result.ReturnMessage.Add("اطلاعات تایید و ارسال شد"); } } else { result.ReturnStatus = false; result.ReturnMessage.Add("اطلاعات معتبر نمی باشد"); } } catch (Exception ex) { CatchException(ex, result, ""); } return(result); }
public async Task <IBusinessResultValue <List <MemberPromotion> > > LoadAsync(int branchId, PromotionReviewStatusEnum promotionReviewStatusId) { var result = new BusinessResultValue <List <MemberPromotion> >(); try { result.ResultValue = await unitOfWork.MemberPromotionDataService.GetAsync(x => x.BranchPromotion.BranchId == branchId && x.BranchPromotion.PromotionReviewStatusId == promotionReviewStatusId , includes : x => new { x.BranchPromotion, x.Member, x.Details }); } catch (Exception ex) { CatchException(ex, result, ""); } return(result); }
public async Task <IBusinessResultValue <BranchPromotion> > LoadBranchPromotionAsync(int branchId, PromotionReviewStatusEnum promotionReviewStatusId) { var result = new BusinessResultValue <BranchPromotion>(); try { result.ResultValue = await unitOfWork.BranchPromotionDataService.GetQuery() .IncludeFilter(x => x.BranchGoalPromotions.Where(y => y.Deleted == false)) .IncludeFilter(x => x.BranchGoalPromotions.Select(y => y.PositionReceiptPromotions.Where(z => z.Deleted == false))) .IncludeFilter(x => x.BranchGoalPromotions.Select(y => y.PositionReceiptPromotions.Select(z => z.PositionType))) .IncludeFilter(x => x.BranchGoalPromotions.Select(y => y.Goal)) .IncludeFilter(x => x.BranchGoalPromotions.Select(y => y.Branch)) .Where(x => x.BranchId == branchId && x.PromotionReviewStatusId == promotionReviewStatusId) .FirstOrDefaultAsync(); } catch (Exception ex) { CatchException(ex, result, ""); } return(result); }