public static decimal GetAdvancePayment(int workerId) { var advanceSum = new WorkerPaymentsEntities().WorkerPayments .ToList().Where(x => x.worker_id == workerId && x.payment_type == (int)PaymentTypes.advance && (x.is_advance_excluded == false || x.is_advance_excluded == null)) .Sum(x => x.amount ?? 0); return(advanceSum); }
public static Classes.Worker.WorkerPaymentModel GetWorkerPaymentModel(WorksEntities dbWorks, WorkerPaymentsEntities dbWorkerPayment) { var model = new Classes.Worker.WorkerPaymentModel { WorkId = MySession.Current.WorkId, CurrentDate = DateTime.Today, Amount = GetSalary(MySession.Current.WorkerId), WorkerWorkList = dbWorks.Works.AsQueryable().Where(x => x.worker_id == MySession.Current.WorkerId).ToList(), PaymentTypeList = GetPaymentTypeList(), WorkerPayments = dbWorkerPayment.WorkerPayments.ToList() .Where(x => x.worker_id == MySession.Current.WorkerId).ToList() }; return(model); }