Exemple #1
0
        public void CheckChangeAppStatus(Guid?appId, string targetState)
        {
            var states = GetAppStates(appId);

            if (states == null)
            {
                throw new ArgumentNullException(nameof(appId), "Невірний id заяви");
            }

            if (string.IsNullOrWhiteSpace(targetState))
            {
                throw new ArgumentNullException(nameof(appId), "Невірна дія");
            }

            var backOfficeAppState = states[nameof(BaseApplication.BackOfficeAppState)];

            if (!IsChangeStatusAllowed(
                    backOfficeAppState,
                    states[nameof(BaseApplication.AppState)],
                    targetState))
            {
                throw BusinessRulesException.CreateUpdateViolationException("Заява", $"{backOfficeAppState}",
                                                                            targetState);
            }
        }
Exemple #2
0
        public bool?IsEditableApp(Guid?appId, bool raiseError = false)
        {
            if (appId == null || appId == Guid.Empty)
            {
                return(null);
            }

            var appStates = GetAppStates(appId);

            if (appStates == null)
            {
                return(null);
            }

            var func = new Func <bool>(delegate
            {
                var BackOfficeAppState = appStates["BackOfficeAppState"];
                var AppState           = appStates["AppState"];

                if (string.IsNullOrEmpty(BackOfficeAppState) && AppState == "Project" ||
                    BackOfficeAppState == "Project" && string.IsNullOrEmpty(AppState))
                {
                    var AppSort = appStates["AppSort"];
                    switch (AppSort)
                    {
                    case "IncreaseToPRLApplication":
                    case "IncreaseToIMLApplication":
                    case "IncreaseToTRLApplication":
                    case "RenewLicenseApplication":
                    case "GetLicenseApplication":
                    case "AdditionalInfoToLicense":
                        return(true);

                    default:
                        return(false);
                    }
                }

                return(false);
            });

            if (func.Invoke())
            {
                return(true);
            }

            if (!raiseError)
            {
                return(false);
            }

            throw BusinessRulesException.CreateNew("Ця заява не може бути редагована!");
        }
Exemple #3
0
        public bool?IsEditableEdoc(Guid?edocId, bool raiseError = false)

        {
            if (edocId == null || edocId == Guid.Empty)
            {
                return(null);
            }

            var func = new Func <bool>(delegate
            {
                var branchId = DataService
                               .GetEntity <BranchEDocument>(x => x.EDocumentId == edocId).First()
                               .BranchId;
                var appId = DataService.GetEntity <ApplicationBranch>(apBrn => apBrn.BranchId == branchId).Single()
                            .LimsDocumentId;
                var appStates = GetAppStates(appId);

                if (appStates[nameof(BaseApplication.AppState)] == "Project" ||
                    appStates[nameof(BaseApplication.BackOfficeAppState)] == "Project")
                {
                    var appSort = appStates[nameof(BaseApplication.AppSort)];
                    switch (appSort)
                    {
                    case "GetLicenseApplication":
                    case "RenewLicenseApplication":
                    case "IncreaseToPRLApplication":
                    case "IncreaseToIMLApplication":
                    case "IncreaseToTRLApplication":
                    case "AddBranchInfoApplication":
                    case "AddBranchApplication":
                    case "AdditionalInfoToLicense":
                        return(true);

                    default:
                        return(false);
                    }
                }

                return(false);
            });

            if (func.Invoke())
            {
                return(true);
            }

            if (!raiseError)
            {
                return(false);
            }

            throw BusinessRulesException.CreateNew("Ця відповідальна одиниця не може бути редагована!");
        }
Exemple #4
0
        public bool?IsEditableContractor(Guid?contractorId, bool raiseError = false)
        {
            if (contractorId == null || contractorId == Guid.Empty)
            {
                return(null);
            }

            var func = new Func <bool>(delegate
            {
                var branchId = DataService
                               .GetEntity <PrlBranchContractor>(contractor => contractor.ContractorId == contractorId).First()
                               .BranchId;
                var appId = DataService.GetEntity <ApplicationBranch>(apBrn => apBrn.BranchId == branchId).Single()
                            .LimsDocumentId;
                var appStates = GetAppStates(appId);

                if (appStates[nameof(BaseApplication.AppState)] == "Project" ||
                    appStates[nameof(BaseApplication.BackOfficeAppState)] == "Project")
                {
                    var appSort = appStates[nameof(BaseApplication.AppSort)];
                    switch (appSort)
                    {
                    case "GetLicenseApplication":
                    case "RenewLicenseApplication":
                    case "ChangeContrApplication":
                    case "IncreaseToPRLApplication":
                    case "AddBranchApplication":
                    case "AdditionalInfoToLicense":
                        return(true);

                    default:
                        return(false);
                    }
                }

                return(false);
            });

            if (func.Invoke())
            {
                return(true);
            }

            if (!raiseError)
            {
                return(false);
            }

            throw BusinessRulesException.CreateNew("Цей контрактний контрагент не може бути редагований!");
        }
Exemple #5
0
        public bool?IsEditableBranch(Guid?branchId, bool raiseError = false)
        {
            if (branchId == null || branchId == Guid.Empty)
            {
                return(null);
            }

            var func = new Func <bool>(delegate
            {
                var appId = DataService.GetEntity <ApplicationBranch>(apBrn => apBrn.BranchId == branchId).Single()
                            .LimsDocumentId;
                var appStates = GetAppStates(appId);
                if (appStates[nameof(BaseApplication.AppState)] == "Project" ||
                    appStates[nameof(BaseApplication.BackOfficeAppState)] == "Project")
                {
                    var appSort = appStates[nameof(BaseApplication.AppSort)];
                    switch (appSort)
                    {
                    case "GetLicenseApplication":
                    case "RenewLicenseApplication":
                    case "AddBranchInfoApplication":
                    case "RemBranchInfoApplication":
                    case "AdditionalInfoToLicense":
                        return(true);

                    case "AddBranchApplication":
                        var branch = DataService.GetEntity <Branch>(br => br.Id == branchId).Single();
                        return(branch.IsFromLicense == null || !branch.IsFromLicense.Value);

                    default:
                        return(false);
                    }
                }

                return(false);
            });

            if (func.Invoke())
            {
                return(true);
            }

            if (!raiseError)
            {
                return(false);
            }

            throw BusinessRulesException.CreateNew("Це МПД не може бути редаговане!");
        }
Exemple #6
0
        public bool?IsEditableMedicine(Guid?medicineId, bool raiseError = false)

        {
            if (medicineId == null || medicineId == Guid.Empty)
            {
                return(null);
            }

            var func = new Func <bool>(delegate
            {
                var medicine  = DataService.GetEntity <ImlMedicine>(x => x.Id == medicineId).FirstOrDefault();
                var appStates = GetAppStates(medicine.ApplicationId);

                if (appStates[nameof(BaseApplication.AppState)] == "Project" ||
                    appStates[nameof(BaseApplication.BackOfficeAppState)] == "Project")
                {
                    var appSort = appStates[nameof(BaseApplication.AppSort)];
                    switch (appSort)
                    {
                    case "AdditionalInfoToLicense":
                    case "GetLicenseApplication":
                    case "RenewLicenseApplication":
                    case "IncreaseToIMLApplication":
                    case "AddBranchApplication":
                        return(true);

                    default:
                        return(false);
                    }
                }

                return(false);
            });

            if (func.Invoke())
            {
                return(true);
            }

            if (!raiseError)
            {
                return(false);
            }

            throw BusinessRulesException.CreateNew("Ця відповідальна одиниця не може бути редагована!");
        }
 /// <summary>
 /// Uplata novca dobivenog iz pricuve
 /// </summary>
 /// <param name="bill">racun</param>
 public virtual void ReceivePaymentFor(Bill bill)
 {
     // moze se samo naplatiti pricuva iz racuna za pricuvu, odnosno ako ga je izdala zgrada
     if (bill.Reserve != null && bill.To != null) {
         bill.SetPaid();
         money += bill.TotalAmountWithTax;
     } else {
         var businessEx = new BusinessRulesException<Reserve>();
         businessEx.AddErrorForModel("Nije moguce naplatiti pričuvu iz računa koji nije račun za pričuvu.");
     }
 }
        /// <summary>
        /// Provjerava da li je trenutni objekt u ispravnom stanju
        /// </summary>
        public virtual void IsValid()
        {
            var errors = new BusinessRulesException<Person>();

            if (!isOibValid()) {
                errors.AddErrorFor(x => x.Oib, "Oib is not valid.");
            }

            if (errors.Errors.Any()) {
                throw errors;
            }
        }
        /// <summary>
        /// Dodjeljuje izvodaca radova na popravak ili odrzavanje
        /// </summary>
        /// <param name="contractor">izvodac radova</param>
        public virtual void SetContractor(Contractor contractor)
        {
            var errors = new BusinessRulesException<Maintenance>();

            if (!BuildingManager.Contractors.Contains(contractor)) {
                errors.AddErrorForModel("Contractor is not working for BuildingManager, so it's invalid.");
            }

            if (!contractor.RepairServices.Contains(ServiceType)) {
                errors.AddErrorForModel("This Contractor can't do needed service.");
            }

            if (errors.Errors.Any()) {
                throw errors;
            }

            this.contractor = new PersonSnapshot(contractor.LegalPerson);
            statusOfMaintenance = StatusOfMaintenance.InProgress;
        }
        public virtual void SetBill(Bill bill)
        {
            var errors = new BusinessRulesException<Maintenance>();

            if(bill.From.Oib != contractor.Oib) {
                errors.AddErrorFor(m => m.Bill,
                    "Constractor who issued bill isn't the same as contractor responsible for the maintenance.");
            }

            if(errors.Errors.Any()) {
                throw errors;
            }

            this.bill = bill;
        }