public Tuple <bool, string> VoteTemporary(VoteModel voteModel) { try { _voteRepository.AddOrUpdate(v => v.RequestId, new Vote { RequestId = voteModel.RequestId, PersonId = voteModel.PersonId, PostId = voteModel.PostId, VoteText = voteModel.VoteText, ReferText = voteModel.VoteDescription, VoteType = voteModel.VoteType, VoteStatus = voteModel.VoteStatus, DateVote = voteModel.DateVote.ToMiladiDate() }); if (voteModel.RequestType == RequestType.Comision) { var commission = _commissionRepository.Find(c => c.RequestId == voteModel.RequestId); if (commission != null) {// اول شماره کمیسیون در متد ایجاد درخواست بود // بر اساس تغییرات خواسته شده شماره کیسیون باید در مرحله صدور رای بیاید commission.CommissionNumber = voteModel.DetailRequestModel.CommissionNumber; _commissionRepository.Update(commission); } } else { var council = _councilRepository.Find(c => c.RequestId == voteModel.RequestId); if (council != null) { // این شماره CommissionNumber // DetailRequestModel در مدل // برای کمیسیون و شورای یکی می باشد council.CouncilNumber = voteModel.DetailRequestModel.CommissionNumber; _councilRepository.Update(council); } } _unitOfWork.SaveChanges(); return(new Tuple <bool, string>(true, "صدور رای موقت با موفقیت انجام شده است")); } catch (Exception exception) { return(new Tuple <bool, string>(false, "عملیات با مشکل مواجه شده است")); } }
public async Task <IEnumerable <PeriodicReportDto> > GetAnnualReport(int year) { List <PeriodicReportDto> periodicReports = new List <PeriodicReportDto>(); for (int i = 1; i <= 12; i++) { PeriodicReportDto periodicReport = new PeriodicReportDto(); periodicReport.Period = Enum.GetName(typeof(eMonths), i - 1); periodicReport.Sales = ( await _saleRepositoryRepository.Find(x => x.Date.Year == year && x.Date.Month == i, x => x.Include(s => s.Payment)) ).Sum(x => x.Payment.Amount); periodicReport.Purchases = ( await _productEntryRepository.Find(x => x.Date.Year == year && x.Date.Month == i && x.IsEntry) ).Sum(x => x.Cost.HasValue ? x.Cost.Value : 0); periodicReport.Commissions = ( await _commissionRepository.Find(x => x.Date.Year == year && x.Date.Month == i) ).Sum(x => x.Value); periodicReport.FixedCosts = ( await _miscellaneousExpensesRepository.Find(x => x.Date.Year == year && x.Date.Month == i && x.IsFixed) ).Sum(x => x.Value); periodicReport.VariableCosts = ( await _miscellaneousExpensesRepository.Find(x => x.Date.Year == year && x.Date.Month == i && !x.IsFixed) ).Sum(x => x.Value); periodicReports.Add(periodicReport); } PeriodicReportDto finalResultReport = new PeriodicReportDto(); finalResultReport.Period = "Totales"; finalResultReport.Sales = periodicReports.Sum(x => x.Sales); finalResultReport.Purchases = periodicReports.Sum(x => x.Purchases); finalResultReport.Commissions = periodicReports.Sum(x => x.Commissions); finalResultReport.FixedCosts = periodicReports.Sum(x => x.FixedCosts); finalResultReport.VariableCosts = periodicReports.Sum(x => x.VariableCosts); periodicReports.Add(finalResultReport); return(periodicReports); }