示例#1
0
        /// <summary>
        /// calculate coefficients for a specific measureset/measure/month and change the state of the dossiers
        /// </summary>
        private void CalculateCoefficients(int fpiId)
        {
            var fpi      = Get(fpiId);
            var dossiers = dossierRepo.GetBy(fpi.MeasuresetId, fpi.MeasureId, fpi.Month, (int)DossierStates.HasIndicators).ToArray();

            if (dossiers.Count() == 0)
            {
                return;
            }
            var measure = u.Get <Measure>(fpi.MeasureId);

            using (var t = new TransactionScope())
            {
                if (!measure.NoContest)
                {
                    var indicatorValues   = ivr.GetBy(fpi.Id).ToArray();
                    var coefficients      = u.GetWhere <Coefficient>(new { dossiers.First().FieldsetId }).ToList();
                    var coefficientValues = ecoCalc.CalculateCoefficientValues(indicatorValues, dossiers, coefficients);
                    coefficientValues.All(o => u.InsertNoIdentity(o) == 1);
                }

                dossiers.All(o => dossierRepo.ChangeState(o.Id, DossierStates.HasCoefficients) == 1);
                t.Complete();
            }
        }
示例#2
0
        public ActionResult GetCountryItem(int?v)
        {
            Check.NotNull(v, "v");

            var country = repo.Get <Country>(v.Value);

            return(Json(new KeyContent(country.Id, country.Name)));
        }
示例#3
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();
            }
        }
示例#4
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));
        }
示例#5
0
 public string GetDistrictName(int districtId)
 {
     return(u.Get <District>(districtId).Name);
 }
示例#6
0
 public ActionResult Edit(int id)
 {
     return(PartialView("Create", Mapper.Map <Feedback, FeedbackInput>(repo.Get <Feedback>(id))));
 }
示例#7
0
        public void DeleteIndicator(int id)
        {
            var o = u.Get <Indicator>(id);

            Do(() => u.Delete <Indicator>(id), FieldsetStates.HasFields, o.FieldsetId);
        }