Пример #1
0
 public void ChangeAmount(int id, decimal amount, decimal amountm)
 {
     using (var t = new TransactionScope())
     {
         var payed = r.GetAmountPayed(id);
         (amount < payed).B("suma introdusa este mai mica decat suma deja autorizata spre plata");
         r.UpdateWhatWhere(new { amount, amountm }, new { id });
         Rerank(id);
         t.Complete();
     }
 }
Пример #2
0
        public void Authorize(int dossierId)
        {
            rules.MustBe(dossierId, DossierStates.Winner);

            var dossier = dossierRepo.Get(dossierId);
            var fpi     = u.Get <Fpi>(dossier.FpiId);

            using (var scope = new TransactionScope())
            {
                if ((fpi.Amount - (fpiRepo.GetAmountPayed(fpi.Id) + dossier.AmountPayed)) < 0)
                {
                    throw new AsmsEx("nu au mai ramas bani in aceasta luna pentru acest dosar");
                }

                dossierRepo.ChangeState(dossierId, DossierStates.Authorized);
                dossierRepo.UpdateWhatWhere(new { FpiId = fpi.Id }, new { dossier.Id });
                scope.Complete();
            }
        }
Пример #3
0
        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));
        }