public void CreateForContract(PaymentOrder o, int id) { o.State = PoState.Registered; using (var t = new TransactionScope()) { var pid = u.Insert(o); u.UpdateWhatWhere <Contract>(new { paymentOrderId = pid }, new { id }); t.Complete(); } }
protected override void Inject(object target) { var props = target.GetType().GetProps(); foreach (var p in props) { if (p.PropertyType == typeof(string)) { p.SetValue(target, "a" + ++s); } else if (p.PropertyType == typeof(int) && !p.Name.EndsWith("Id")) { p.SetValue(target, ++i); } else if (p.PropertyType == typeof(DateTime)) { p.SetValue(target, DateTime.Now); } else if (p.PropertyType.IsSubclassOf(typeof(Entity))) { Console.WriteLine(" create a " + p.PropertyType.Name); dynamic o = Activator.CreateInstance(p.PropertyType).InjectFrom(new Fill(urepo, true)); o = urepo.Insert(o); urepo.Save(); p.SetValue(target, o); } else if (p.PropertyType.IsGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(ICollection <>) && !isChild) { var t = p.PropertyType.GetGenericArguments()[0]; if (!t.IsSubclassOf(typeof(DelEntity))) { continue; } var tlist = typeof(List <>).MakeGenericType(t); dynamic list = Activator.CreateInstance(tlist); Console.WriteLine(" creating a list of " + t.Name); for (var k = 0; k < 3; k++) { Console.WriteLine(" create a " + t.Name); dynamic o = Activator.CreateInstance(t).InjectFrom(new Fill(urepo, true)); o = urepo.Insert(o); urepo.Save(); Console.WriteLine(" add " + t.Name + " to list"); list.Add(o); } p.SetValue(target, list); } } }
protected override void Inject(object target) { var props = target.GetProps(); for (var j = 0; j < props.Count; j++) { var p = props[j]; if (p.PropertyType == typeof(string)) { p.SetValue(target, "a" + ++s); } else if (p.PropertyType == typeof(int) && !p.Name.EndsWith("Id")) { p.SetValue(target, ++i); } else if (p.PropertyType == typeof(DateTime)) { p.SetValue(target, DateTime.Now); } else if (p.PropertyType.IsSubclassOf(typeof(DelEntity))) { dynamic o = Activator.CreateInstance(p.PropertyType).InjectFrom(new Fill(u, true)); u.Insert(o); u.Save(); p.SetValue(target, o); } else if (p.PropertyType.IsGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(ICollection <>) && !isChild) { var t = p.PropertyType.GetGenericArguments()[0]; if (!t.IsSubclassOf(typeof(DelEntity))) { continue; } var tlist = typeof(List <>).MakeGenericType(t); dynamic list = Activator.CreateInstance(tlist); for (var k = 0; k < 3; k++) { dynamic o = Activator.CreateInstance(t).InjectFrom(new Fill(u, true)); u.Insert(o); u.Save(); list.Add(o); } p.SetValue(target, list); } } }
public void Disqualify(int id, string reason) { rules.MustNotBe(id, DossierStates.Authorized); using (var scope = new TransactionScope()) { u.Insert(new Disqualifier { DossierId = id, Reason = reason }); dossierRepo.UpdateWhatWhere(new { Disqualified = true }, new { Id = id }); scope.Complete(); } }
public override int Create(Agreement o) { var contract = u.Get <Contract>(o.ContractId); var dossier = u.Get <Dossier>(contract.DossierId); (dossier.CreatedDate.Year != DateTime.Now.Year).B("acest dosar a fost creat in alt an"); var fpi = u.GetWhere <Fpi>(new { dossier.MeasureId, dossier.MeasuresetId, State = FpiState.Agreement }).SingleOrDefault(); fpi.IsNull().B("la moment nu este posibil crearea unui acord aditional"); var payed = fpiRepo.GetAmountPayed(fpi.Id); ((fpi.Amount - payed - o.Amount) < 0).B("la moment nu sunt bani deajuns pentru acest acord"); o.FpiId = fpi.Id; var ags = u.GetWhere <Agreement>(new { o.ContractId }); o.Nr = (byte)(ags.Count() == 0 ? 1 : 1 + ags.Max(a => a.Nr)); return(u.Insert(o)); }
public void CreateIndicator(Indicator o) { Do(() => u.Insert(o), FieldsetStates.HasFields, o.FieldsetId); }