Esempio n. 1
0
        public BusinessRuleResult Execute(IEntity instance)
        {
            var failed           = false;
            var request          = instance as Framework.DomainModel.Entities.Request;
            var validationResult = new List <ValidationResult>();

            if (request != null)
            {
                if (request.LocationFrom <= 0)
                {
                    var mess = string.Format(SystemMessageLookup.GetMessage("RequiredTextResourceKey"), "From");
                    validationResult.Add(new ValidationResult(mess));
                    failed = true;
                }

                if (request.LocationTo <= 0)
                {
                    var mess = string.Format(SystemMessageLookup.GetMessage("RequiredTextResourceKey"), "To");
                    validationResult.Add(new ValidationResult(mess));
                    failed = true;
                }

                if (request.LocationFrom > 0 && request.LocationTo > 0 && request.LocationTo == request.LocationFrom)
                {
                    var mess = string.Format(SystemMessageLookup.GetMessage("MustDifferentResourceKey"), "From", "To");
                    validationResult.Add(new ValidationResult(mess));
                    failed = true;
                }

                if (request.CourierId == null || request.CourierId == 0)
                {
                    var mess = string.Format(SystemMessageLookup.GetMessage("RequiredTextResourceKey"), _franchiseeTenantService.GetDisplayNameForCourier());
                    validationResult.Add(new ValidationResult(mess));
                    failed = true;
                }
                if (request.SendingTime == null && request.IsStat == false)
                {
                    var mess = string.Format(SystemMessageLookup.GetMessage("RequiredTextResourceKey"), "Dispatch Time");
                    validationResult.Add(new ValidationResult(mess));
                    failed = true;
                }
                else
                {
                    if (request.SendingTime < DateTime.UtcNow && request.IsStat == false)
                    {
                        var mess = string.Format(SystemMessageLookup.GetMessage("MustGreaterThan"), "Dispatch Time", "Current Time");
                        validationResult.Add(new ValidationResult(mess));
                        failed = true;
                    }
                }
                if (request.StartTime.Year == 1)
                {
                    var mess = string.Format(SystemMessageLookup.GetMessage("RequiredTextResourceKey"), "Arrival Window From");
                    validationResult.Add(new ValidationResult(mess));
                    failed = true;
                }
                if (request.EndTime.Year == 1)
                {
                    var mess = string.Format(SystemMessageLookup.GetMessage("RequiredTextResourceKey"), "Arrival Window To");
                    validationResult.Add(new ValidationResult(mess));
                    failed = true;
                }

                if (request.StartTime.Year != 1 && request.SendingTime != null && request.SendingTime > request.StartTime)
                {
                    var mess = string.Format(SystemMessageLookup.GetMessage("MustGreaterThan"), "Arrival Window From", "Dispatch Time");
                    validationResult.Add(new ValidationResult(mess));
                    failed = true;
                }

                //if (request.StartTime.Year != 1 && request.EndTime.Year != 1 && request.StartTime < DateTime.UtcNow)
                //{
                //    var mess = string.Format(SystemMessageLookup.GetMessage("MustGreaterThan"), "Arrival Window From", "Current Time");
                //    validationResult.Add(new ValidationResult(mess));
                //    failed = true;
                //}

                //if (request.StartTime.Year != 1 && request.EndTime.Year != 1 && request.EndTime < DateTime.UtcNow)
                //{
                //    var mess = string.Format(SystemMessageLookup.GetMessage("MustGreaterThan"), "Arrival Window To", "Current Time");
                //    validationResult.Add(new ValidationResult(mess));
                //    failed = true;
                //}

                if (request.StartTime.Year != 1 && request.EndTime.Year != 1 && request.EndTime <= request.StartTime)
                {
                    var mess = string.Format(SystemMessageLookup.GetMessage("MustGreaterThan"), "Arrival Window To", "Arrival Window From");
                    validationResult.Add(new ValidationResult(mess));
                    failed = true;
                }
                var result = new BusinessRuleResult(failed, "", instance.GetType().Name, instance.Id, PropertyNames, Name)
                {
                    ValidationResults = validationResult
                };
                return(result);
            }
            return(new BusinessRuleResult());
        }
Esempio n. 2
0
        public JsonResult GetDisplayLabel()
        {
            var courier = _franchiseeTenantService.GetDisplayNameForCourier();

            return(Json(new { data = courier }, JsonRequestBehavior.AllowGet));
        }