Esempio n. 1
0
        public bool SaveBusinessRule(BusinessRulesDTO businessRule)
        {
            var business = operationalDataContext.CorrelationBusinessRules.FirstOrDefault(x => x.BusinessRuleId == businessRule.BusinessRuleId);

            if (business == null)
            {
                business = new CorrelationBusinessRule();
                business.BusinessName            = businessRule.BusinessName;
                business.BusinessRuleId          = businessRule.BusinessRuleId;
                business.CreatedAt               = businessRule.CreatedAt;
                business.CreatedBy               = businessRule.CreatedBy;
                business.InsideCityOverSpeedId   = businessRule.InsideCityOverSpeedId;
                business.InsideCityOverSpeedQty  = businessRule.InsideCityOverSpeedQty;
                business.IsDeleted               = businessRule.IsDeleted;
                business.IsOverSpeedInsideCity   = businessRule.IsOverSpeedInsideCity;
                business.IsOverSpeedOutsideCity  = businessRule.IsOverSpeedOutsideCity;
                business.IsTrafficCross          = businessRule.IsTrafficCross;
                business.LastModifiedAt          = businessRule.LastModifiedAt;
                business.LastModifiedBy          = businessRule.LastModifiedBy;
                business.OutsideCityOverSpeedId  = businessRule.OutsideCityOverSpeedId;
                business.OutsideCityOverSpeedQty = businessRule.OutsideCityOverSpeedQty;
                business.PriorityId              = businessRule.PriorityId;
                business.RuleInterval            = businessRule.RuleInterval;
                business.TrafficCrossQty         = businessRule.TrafficCrossQty;
                business.TrafficCrossTimesId     = businessRule.TrafficCrossTimesId;
                business.VehicleTypeId           = businessRule.VehicleTypeId;
                operationalDataContext.CorrelationBusinessRules.Add(business);
            }
            else
            {
                business.IsDeleted = businessRule.IsDeleted;
            }
            return(operationalDataContext.SaveChanges() > 0);
        }
Esempio n. 2
0
        public UpdateAdminPageControlViewModel(BusinessRulesDTO businessRulesDto)
        {
            _businessRulesDTO = businessRulesDto;

            PriorityTypesList      = new ObservableCollection <BusinessRulePriorityDTO>();
            OverSpeedList          = new ObservableCollection <OverSpeedDTO>();
            TrafficCrossList       = new ObservableCollection <TrafficCrossDTO>();
            VehicleTypesList       = new ObservableCollection <VehicleTypeDTO>();
            _client                = new ServiceLayerClient();
            AddBusinessRuleCommand = new Command(SaveBusinessRule);
            LoadData();

            SetSelectedRuleDetails();

            IsUpdateGridEnabled = true;
            //IsRuleEnabled = true;
        }
        private void SaveBusinessRule(object parameter)
        {
            if (IsAddGridEnabled)
            {
                IsAddGridEnabled = false;
                BusinessRulesDTO businessRule = new BusinessRulesDTO
                {
                    BusinessName            = BusinessRuleName,
                    CreatedAt               = DateTime.Now,
                    CreatedBy               = 1,
                    InsideCityOverSpeedQty  = NumOfViolnsInCity,
                    IsOverSpeedInsideCity   = SpeedInsideCityAdded,
                    IsOverSpeedOutsideCity  = SpeedOutsideCityAdded,
                    IsTrafficCross          = RedLgtCrosdAdded,
                    OutsideCityOverSpeedQty = NumOfViolnsOutCity,
                    RuleInterval            = RuleIntTimeValue,
                    TrafficCrossQty         = RedLgtCrosngNumOfViolnsValue,
                    IsDeleted               = IsRuleDisabled,
                };

                if (RulePriority != null)
                {
                    businessRule.PriorityId = RulePriority.PriorityID;
                }
                if (SpeedInsideCityAdded && SpeedThshldInCity != null)
                {
                    businessRule.InsideCityOverSpeedId = SpeedThshldInCity.OverSpeedId;
                }
                if (SpeedOutsideCityAdded && SpeedThshldOutCity != null)
                {
                    businessRule.OutsideCityOverSpeedId = SpeedThshldOutCity.OverSpeedId;
                }
                if (RedLgtCrosdAdded && RedLgtCrosngSecondsValue != null)
                {
                    businessRule.TrafficCrossTimesId = RedLgtCrosngSecondsValue.TrafficCrossId;
                }
                if (VehicleType != null && VehicleType.VehicleTypeEn != "Any")
                {
                    businessRule.VehicleTypeId = VehicleType.VehicleTypeID;
                }


                var res = _client.SaveBusinessRuleAsync(businessRule);
                res.ContinueWith(x => AddBusinessRuleResult(x.Result));
            }
        }