public void AssureAbilityToCreateDossier() { var fs = fsService.GetActive(); fs.IsNull().B("la moment nu exista nici un set de campuri activ"); (fs.Year != DateTime.Now.Year).B("setul de campuri activ nu este pentru anul curent"); var m = mService.GetActive(); m.IsNull().B("la moment nu exista nici un set de masuri activ"); (m.Year != DateTime.Now.Year).B("setului de masuri activ nu este pentru anul curent"); }
/// <summary> /// create a new dossier, if it can be created /// </summary> /// <param name="o">the dossier to be created</param> /// <returns>the id of the new dossier</returns> public int Create(Dossier o) { var fs = fieldsetService.GetActive(); var ms = measuresetService.GetActive(); (fs == null).B("la moment nu exista nici un set de campuri activ"); (ms == null).B("la moment nu exista nici un se de masuri activ"); var measure = u.Get <Measure>(o.MeasureId); o.FieldsetId = fs.Id; o.MeasuresetId = ms.Id; o.AmountPayed = o.AmountRequested; o.StateId = measure.NoContest ? DossierStates.HasIndicators : DossierStates.Registered; o.CreatedDate = DateTime.Now; var fpis = fpiRepo.GetWhere(new { o.MeasureId, o.MeasuresetId, o.CreatedDate.Month }); (fpis.Count() == 0).B("la moment in planul financiar pentru aceasta luna si masura nu a fost stabilita nici o suma"); var fpi = fpis.Single(); o.FpiId = fpi.Id; int id; using (var scope = new TransactionScope()) { id = dossierRepo.Insert(o); var d = dossierRepo.Get(id); d.Code = d.CreatedDate.AddYears(-2000).Year + d.CreatedDate.Month.ToString("00") + u.Get <District>(d.DistrictId.Value).Code + d.Id; dossierRepo.UpdateWhatWhere(new { d.Code }, new { d.Id }); scope.Complete(); } return(id); }