public void Load(IEnumerable <SalesUnit> salesUnitsIn) { var salesUnits = salesUnitsIn.Where(x => !x.IsPaid && !x.IsLoosen && x.Project.ForReport).ToList(); var payments = new List <Payment1>(); foreach (var salesUnit in salesUnits) { payments.AddRange(salesUnit.PaymentsPlannedCalculated.Select(paymentPlanned => new Payment1(salesUnit, paymentPlanned))); } var groups = payments.GroupBy(x => new { x.SalesUnit.Cost, x.SalesUnit.SumNotPaid, x.SalesUnit.Product, x.SalesUnit.Project, x.SalesUnit.Facility, x.SalesUnit.Specification, x.PaymentPlanned.Part, x.PaymentPlanned.Date, x.PaymentPlanned.Condition }) .OrderBy(x => x.Key.Date) .Select(x => new PaymentsPlanGroup(x)) .Where(x => x.Sum > 0.00001) .ToList(); Payments.Clear(); Payments.AddRange(groups); }
/// <summary> /// Adds random data to the context /// </summary> /// <param name="paymentCount">Number of Payments to add</param> /// <returns>Task result</returns> public void AddRandomData(byte paymentCount = 20) { var fixture = new Fixture(); fixture.Customize <Payment>(f => f .With(p => p.Visible, fixture.Create <byte>() % 2 == 0) .With(p => p.SubmissionDate, DateTime.Now.AddTicks(fixture.Create <long>() % DateTime.Now.AddYears(-1).Ticks * -1)) ); Payments.AddRange(fixture.CreateMany <Payment>(paymentCount)); this.Loaded = true; this.SaveChanges(); }
protected override void LoadedMethod() { _unitOfWork = Container.Resolve <IUnitOfWork>(); var units = _unitOfWork.Repository <SalesUnit>().GetAllAsNoTracking(); var payments = new List <PlanPayment>(); foreach (var unit in units) { payments.AddRange(unit.PaymentsPlannedCalculated.Select(x => new PlanPayment(unit, x))); } Payments.Clear(); Payments.AddRange(PaymentsGroup.GetGroups(payments)); }