Пример #1
0
 public CartService(IUnitOfWork unitOfWork, IValidationDictionary validationDictionary,
                    IConfiguration configuration)
 {
     _unitOfWork           = unitOfWork;
     _validationDictionary = validationDictionary;
     _config = configuration;
 }
Пример #2
0
 public void ValidateIsUpdatingExistingProduct(string productId, IValidationDictionary validationDictionary)
 {
     if (_repository.Get(productId) == null)
     {
         validationDictionary.AddModelError(nameof(productId), "ProductId does not exist. Please use Post for creating a Product and Put for updating a product.");
     }
 }
Пример #3
0
 public HAVHomeService(IValidationDictionary aValidationDictionary, IHAVIssueService anIssueService, IFriendService<User, Friend> aFriendService, IHAVHomeRepository aRepository)
 {
     theValidationDictionary = aValidationDictionary;
     theIssueService = anIssueService;
     theFriendService = aFriendService;
     theHomeRepository = aRepository;
 }
Пример #4
0
 public override void Merge(IValidationDictionary vd)
 {
     foreach (var err in vd.ErrorDictionary)
     {
         AddError(err.PropertyName, err.Message);
     }
 }
Пример #5
0
 public ClassController()
 {
     UserInformationFactory.SetInstance(UserInformation<User, WhoIsOnline>.Instance(new HttpContextWrapper(System.Web.HttpContext.Current), new WhoIsOnlineService<User, WhoIsOnline>(new EntityWhoIsOnlineRepository()), new GetUserStrategy()));
     theValidationDictionary = new ModelStateWrapper(this.ModelState);
     theClassService = new ClassService(theValidationDictionary);
     theUniversityService = new UniversityService(theValidationDictionary);
 }
Пример #6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="key">Error Key</param>
 /// <param name="erbag">Error Bag</param>
 public ValidationItem(string key,IValidationDictionary erbag)
 {
     if (string.IsNullOrEmpty(key)) throw new ArgumentNullException("key");
     if (erbag==null) throw new ArgumentNullException("erbag");
     _erbag = erbag;
     _key = key;
 }
Пример #7
0
        public IssueController()
        {
            theValidationDictionary = new ModelStateWrapper(this.ModelState);

            theIssueService = new HAVIssueService(theValidationDictionary);
            theIssueReplyService = new HAVIssueReplyService(theValidationDictionary);
        }
 public CustomResourcesService(IValidationDictionary validationDictionary, IEntityCustomResourcesRepository repository)
 {
     _validationDictionary = validationDictionary;
     _repository = repository;
     //_userHelper = new UserHelper();
     //_userFasade = new UserFacade(_validationDictionary);
 }
        public Domain.Observation Add(
            IValidationDictionary validationDictionary,
            Domain.Observation observation,
            HttpPostedFileBase postedFile)
        {
            if (!Validate(validationDictionary, observation))
            {
                return(null);
            }

            SetObservationValues(observation);

            var data = _observationRepository.Create();

            _observationRepository.Add(data);

            Mapper.Map(observation, data);

            //Reset the observation ID so that consumers cannot set this.
            data.ObservationId = 0;

            SaveFile(data, postedFile);
            _context.SaveChanges();

            //Map back to the domain so we can use the full
            //result in the web site for sending email, etc.

            return(Mapper.Map <Domain.Observation>(data));
        }
Пример #10
0
 public AccountService(DBContext context, IAccountRepository accountRepository, IValidationDictionary validationDictionary, IConfiguration config)
 {
     //_context = context;
     _accountRepository    = accountRepository;
     _validationDictionary = validationDictionary;
     _config = config;
 }
Пример #11
0
        /// <summary>
        /// 根据行政编号获取最深的行政区划信息(可根据Parent获取其父级区划),注意其转化为字符串长度必须为偶数
        /// </summary>
        /// <param name="code"></param>
        /// <param name="dictionary"></param>
        /// <returns></returns>
        public static Area GetDeepestArea(int code, IValidationDictionary <int, string> dictionary)
        {
            //按GBT2260 - 2007版本说明,已撤销移除的区域编号不会被其它地方使用,那么完全可以只需要GBT2260基类,然后将已移除的行政区划加入Dictonary即可
            //否则的话,可以每期GBT2260标准都如现在一样,设置对应的类,然后按出生日期确定算法从这些集合中找到对应的区域编号
            Area area     = null;
            Area lastArea = null;
            var  dic      = dictionary.GetDictionary();

            while (code > 0)
            {
                if (code < 10)
                {
                    throw new ArgumentException("行政区划代码错误");
                }
                //在这里才做if判断是为了防止因为GBT2260标准变化导致的区域id无法获取的情况
                if (dic.ContainsKey(code))
                {
                    var tmpArea = new Area(code, dic[code]);
                    if (area == null)
                    {
                        area = tmpArea;
                    }
                    else
                    {
                        lastArea.Parent = tmpArea;
                    }
                    lastArea = tmpArea;
                }
                code /= 100;
            }
            return(area);
        }
 public TransactionService(IValidationDictionary validationDictionary)
 {
     _validationDictionary = validationDictionary;
     _repository = new EntityTransactionRepository();
     PaymentMethodService = new PaymentMethodService(validationDictionary);
     _profileService = new ProfileService(validationDictionary);
 }
Пример #13
0
        }                                                                         //we cannot return it directly from ContextManager becuase sometimes it may be null


        protected RepositoryBase(ContextManager <T> contextManager, Func <Y> unitOfRepositoryInstantiator)
        {
            ContextManager = contextManager;
            if (contextManager == null)
            {
                context = new T();                                        // throw new Exception("ContextManager cannot be empty for Repository creation");
                ValidationDictionary = new DefaultValidationDictionary(); //when contextmanager is null.
            }
            else
            {
                context = contextManager.Context;
                ValidationDictionary = ContextManager.ValidationDictionary;
            }

            //handling events
            context.OnChangesSaving          += OnChangesSaving;
            context.OnChangesSaved           += OnChangesSaved;
            context.OnChangesCommitted       += OnChangesCommitted;
            context.OnBeforeTransactionStart += OnBeforeTransactionStart;

            //if (contextManager == null)//because committing transaction is handled with context manager. when there is no any context manager, so we don't have any outer transaction(transactionscope indeed). so when the changes saved, it means commission too.
            //{
            //    context.OnChangesSaved += (o) =>
            //    {
            //        context.OnChangesCommittedEventInvoker();
            //    };
            //}

            _UoRInstantiator = unitOfRepositoryInstantiator;
        }
 public MarketplaceController()
 {
     UserInformationFactory.SetInstance(UserInformation<User, WhoIsOnline>.Instance(new HttpContextWrapper(System.Web.HttpContext.Current), new WhoIsOnlineService<User, WhoIsOnline>(new EntityWhoIsOnlineRepository()), new GetUserStrategy()));
     theValidation = new ModelStateWrapper(this.ModelState);
     theMarketplaceService = new MarketplaceService(theValidation);
     theUniversityRepo = new EntityUniversityRepository();
 }
Пример #15
0
 public GeneralLedgerService(IValidationDictionary validationDictionary, IConfiguration config)
 {
     _config            = config;
     client.BaseAddress = new System.Uri("https://localhost:44368/");
     client.DefaultRequestHeaders.Accept.Clear();
     client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
 }
 /// <summary>
 /// 把錯誤訊息記錄到IValidationDictionary的物件裡面
 /// </summary>
 /// <param name="validationDictionary">儲存目前Validation結果的Dictionary</param>
 /// <param name="propertyErrors">要記錄到ValidationDictionary裡面的錯誤訊息</param>
 public static void AddValidationErrors(this IValidationDictionary validationDictionary, IValidationErrors propertyErrors)
 {
     foreach (var databaseValidationError in propertyErrors.Errors)
     {
         validationDictionary.AddError(databaseValidationError.PropertyName, databaseValidationError.PropertyExceptionMessage);
     }
 }
 public SSHService(IValidationDictionary validationDictionary)
     : this(validationDictionary,
     new EntitySSHRepository(),
     new PPPSecretService(validationDictionary),
     new ProfileService(validationDictionary),
     new PoolService(validationDictionary))
 {
 }
 public ServiceService(IValidationDictionary validationDictionary, IServiceRepository repository,
     ISystemServicesService systemService)
 {
     _validationDictionary = validationDictionary;
     _userHelper = new UserHelper();
     _repository = repository;
     _systemService = systemService;
 }
Пример #19
0
 public HAVIssueService(IValidationDictionary aValidationDictionary, IHAVIssueRepository aRepository, IHAVIssueReplyRepository anIssueReplyRepo,
                        IHAVIssueReplyCommentRepository anIssueReplyCommentRepo)
 {
     theValidationDictionary = aValidationDictionary;
     theIssueRepository = aRepository;
     theIssueReplyRepository = anIssueReplyRepo;
     theIssueReplyCommentRepository = anIssueReplyCommentRepo;
 }
Пример #20
0
 public EfSiteService(IValidationDictionary validationDictionary, IUnitOfWork unitOfWork)
 {
     _newSiteService       = new UrlService();
     _channelService       = new EfChannelService(unitOfWork);
     _validationDictionary = validationDictionary;
     _uow   = unitOfWork;
     _items = _uow.Set <Site>();
 }
Пример #21
0
        public WareHouseService(IValidationDictionary validationDictionary, IWareHouseRepository warehouserepository, ICouponRepository couponrepository, IDetailCouponRepository detailCouponrepository, IProductRepository productRepository)

        {
            _validationDictionary   = validationDictionary;
            _warehouserepository    = warehouserepository;
            _couponrepository       = couponrepository;
            _detailCouponrepository = detailCouponrepository;
            _productrepository      = productRepository;
        }
Пример #22
0
 public CashTransactionController(ICashRepository cashRepository, ICashService cashService, IValidationDictionary validationDictionary, IConfiguration config,
                                  UserManager <ApplicationUser> userManager)
 {
     _cashRepository       = cashRepository;
     _cashService          = cashService;
     _validationDictionary = validationDictionary;
     _userManager          = userManager;
     _config = config;
 }
Пример #23
0
 public UserFacade(IValidationDictionary validationDictionary)
 {
     _validationDictionary = validationDictionary;
     UserService = new UserService(validationDictionary);
     ClientService = new ClientService(validationDictionary);
     SecretService = new SecretService(validationDictionary);
     LoadMoneyService = new LoadMoneyService(validationDictionary, this);
     StatusService = new StatusService(validationDictionary);
 }
Пример #24
0
 public override bool Validate(IValidationDictionary validationDictionary)
 {
     if (Value.IsEmpty())
     {
         validationDictionary.AddError("Properties", "A file upload is required");
         return(false);
     }
     return(true);
 }
Пример #25
0
 public GenericRepositoryAsync(IValidationDictionary validationDictionary, DbContext context)
 {
     ValidationDictionary = validationDictionary;
     Context = context;
     if (context != null)
     {
         DbSet = context.Set <T>();
     }
 }
 public UserController()
 {
     _ctx = new CurrentContext();
     validationDictionary = new ModelStateWrapper(ModelState);
     _facade = new UserFacade(validationDictionary);
     _sshSecretService = new SshSecretService(validationDictionary, true);
     _statusService = new StatusService(validationDictionary);
     _profileService = new ProfileService(validationDictionary);
 }
 public static bool RaiseError(IValidationDictionary validationDictionary, string fieldName, string errorMessage)
 {
     if (validationDictionary != null)
     {
         validationDictionary.AddError(fieldName, errorMessage);
         return(false);
     }
     throw new Exception(errorMessage);
 }
 public static void ValidDateOfBirth(IValidationDictionary aValidationDictionary, DateTime aDateOfBirth)
 {
     if (aDateOfBirth.Year == 1) {
         aValidationDictionary.AddError("DateOfBirth", aDateOfBirth.ToString(), "Date of Birth required.");
     }
     if (aDateOfBirth > DateTime.Today.AddYears(-18)) {
         aValidationDictionary.AddError("DateOfBirth", aDateOfBirth.ToString(), "You must be at least 18 years old.");
     }
 }
Пример #29
0
 public SectorCodeService(IAMPRepository ampRepository, IValidationDictionary validationDictionary, IComponentValidator componentValidator)
 {
     _ampRepository         = ampRepository;
     _personService         = new DemoPersonService();
     _inputSectorCodeReader = new InputSectorCodeReader(_ampRepository);
     _inputSectorCodeWriter = new InputSectorCodeWriter(_ampRepository);
     _validationDictionary  = validationDictionary;
     _componentValidator    = componentValidator;
 }
Пример #30
0
 public SellerService(IValidationDictionary validationDictionary, IBillRepository billrepository, IProductRepository productrespository, IBillDetailRespository billdetailrepository, ICustomerRepository customerrepository, ICodeSalesRepository coderepository)
 {
     _validationDictionary = validationDictionary;
     _billrepository       = billrepository;
     _productrepository    = productrespository;
     _billdetailrepository = billdetailrepository;
     _customerrepository   = customerrepository;
     _codesrepository      = coderepository;
 }
Пример #31
0
 public override bool Validate(IValidationDictionary validationDictionary)
 {
     if (OptionID == 0)
     {
         validationDictionary.AddError("Properties", "You must select an option");
         return(false);
     }
     return(true);
 }
Пример #32
0
 public AccountService(IValidationDictionary modelState, IRepository <Account> accountRepo,
                       IRepository <AccountStatus> accountStatusRepo,
                       IRepository <Wallet> walletRepo)
 {
     ModelState = modelState;
     //
     _accountRepo       = accountRepo;
     _accountStatusRepo = accountStatusRepo;
     _walletRepo        = walletRepo;
 }
Пример #33
0
 public UserService(IValidationDictionary validationDictionary, IUserRespository respository,
     ICategoryRespository categoryRespository, IEventRespository eventRespository,
     INotificationRespository notificationRespository)
 {
     _respository = respository;
     _categoryRespository = categoryRespository;
     _validationDictionary = validationDictionary;
     _eventRespository = eventRespository;
     _notificationRespository = notificationRespository;
 }
 public SSHService(IValidationDictionary validationDictionary, ISSHRepository repository,
     IPPPSecretService pppSecretService, IProfileService pppProfileService,
     IPoolService poolService)
 {
     _validationDictionary = validationDictionary;
     _repository = repository;
     _pppSecretService = pppSecretService;
     _pppProfileService = pppProfileService;
     _poolService = poolService;
 }
Пример #35
0
 public TemplateController(
     ITemplateService templateService,
     UserManager <ApplicationUser> userManager,
     IValidationDictionary validationDictionary,
     IConfiguration config)
 {
     _templateService = templateService;
     _config          = config;
     _userManager     = userManager;
 }
Пример #36
0
        public Product Update(string productId, ProductRequest productRequest, IValidationDictionary validationDictionary)
        {
            ValidateIsUpdatingExistingProduct(productId, validationDictionary);
            if (!validationDictionary.IsValid)
            {
                return(null);
            }
            var product = _factory.BuildWithExistingId(productId, productRequest);

            return(_repository.Update(product));
        }
Пример #37
0
 public ContextManager(IValidationDictionary validationDictionary, Func <T> contextInstantiator = null)
 {
     Context              = contextInstantiator == null ? new T() : contextInstantiator();
     ContextBase          = Context;
     ValidationDictionary = validationDictionary ?? new DefaultValidationDictionary();
     if (!_isFullTextSearchInitiated)
     {
         _isFullTextSearchInitiated = true;
         DbInterception.Add(new FtsInterceptor());
     }
 }
Пример #38
0
 public ContextManager(IValidationDictionary validationDictionary)
 {
     Context              = new T();
     ContextBase          = Context;
     ValidationDictionary = validationDictionary ?? new DefaultValidationDictionary();
     if (!_isFullTextSearchInitiated)
     {
         _isFullTextSearchInitiated = true;
         DbInterception.Add(new FtsInterceptor());
     }
 }
 /// <summary>
 /// copies errors to another dictionary
 /// </summary>
 /// <param name="other"></param>
 public void CopyTo(IValidationDictionary other)
 {
     if (other == null)
     {
         throw new ArgumentNullException("other");
     }
     foreach (var kv in err)
     {
         other.AddError(kv.Key, kv.Value);
     }
 }
Пример #40
0
        /// <summary>
        /// Validate form-level request
        /// </summary>
        /// <param name="validationDictionary"></param>
        public bool ValidateRequest(IValidationDictionary validationDictionary)
        {
            var requestDictionary = new ValidationDictionary();

            if (Password != ConfirmPassword)
            {
                requestDictionary.AddError("Password", "Passwords do not match.");
            }
            validationDictionary.Merge(requestDictionary);
            return(requestDictionary.IsValid);
        }
 public ClientInServicesService(IValidationDictionary validationDictionary,
     IClientInServicesRepository repository)
 {
     _validationDictionary = validationDictionary;
     _repository = repository;
     //_clientService = new ClientService(validationDictionary);
     _serviceService = new ServiceService(validationDictionary);
     //_transactionService = new AccountTransactionService(validationDictionary);
     _userHelper = new UserHelper();
     _userFasade = new UserFacade(_validationDictionary);
 }
Пример #42
0
        // add child node to item data list
        private static ArrayList FlatTreeData(IQueryable data, int ExcelOutputLevel, IValidationDictionary validationDictionary)
        {
            ArrayList finalResults = ConvertQueryToList(data);
            ArrayList results      = ConvertQueryToList(data);

            if (results.Count > 0)
            {
                Type           resultsType      = results[0].GetType();
                PropertyInfo[] resultProperties = resultsType.GetProperties();

                foreach (var item in results)
                {
                    int counter = 1;
                    foreach (var property in resultProperties)
                    {
                        if (property.Name == "Children")
                        {
                            var children = property.GetValue(item);
                            var List     = (object[])children;
                            if (List != null && List.Any())
                            {
                                foreach (var node in List)
                                {
                                    string ChildTitle = node.GetType().GetProperty("Title").GetValue(node).ToString();
                                    string spaces     = new string(' ', counter * 8);
                                    ChildTitle = spaces + ChildTitle;
                                    node.GetType().GetProperty("Title").SetValue(node, ChildTitle);
                                }
                                var itemindex = finalResults.IndexOf(item);
                                //add the first Level to result

                                if (ExcelOutputLevel > counter)
                                {
                                    finalResults.InsertRange(itemindex + 1, List);

                                    counter++;
                                    if (ExcelOutputLevel > counter)
                                    {
                                        foreach (var ch in List)
                                        {
                                            var ar1 = AddChildToResult(ch, finalResults, ExcelOutputLevel, counter, validationDictionary);
                                        }
                                    }
                                }
                            }
                        }
                        ;
                    }
                }
            }
            return(finalResults);
        }
Пример #43
0
        public void CheckTitleNote(string propatyName, string note, string title, IValidationDictionary validationDic)
        {
            if (validationDic == null)
            {
                throw new ArgumentNullException(nameof(validationDic));
            }

            if (!string.IsNullOrEmpty(note) && !string.IsNullOrEmpty(title) && note.IndexOf(title, StringComparison.Ordinal) < 0)
            {
                validationDic.AddError(propatyName, "本文中にタイトルが記述されていません。");
                validationDic.AddError(propatyName, "もひとつエラー。");
            }
        }
Пример #44
0
        public static bool ValidPassword(IValidationDictionary aValidationDictionary, string aPassword, string aRetypedPassword)
        {
            if (aPassword.Trim().Length == 0) {
                aValidationDictionary.AddError("Password", "", "Password is required.");
            }
            if (aRetypedPassword == null || aRetypedPassword.Trim().Length == 0) {
                aValidationDictionary.AddError("RetypedPassword", "", "Please type your password again.");
            } else if (!aPassword.Equals(aRetypedPassword)) {
                aValidationDictionary.AddError("RetypedPassword", "", "Passwords must match.");
            }

            return aValidationDictionary.isValid;
        }
Пример #45
0
        public Memo AddMemo(Memo memo, IValidationDictionary validationDic)
        {
            if (validationDic == null)
            {
                throw new ArgumentNullException(nameof(validationDic));
            }
            if (validationDic.IsValid)
            {
                return(_repository.Add(memo));
            }

            return(memo);
        }
Пример #46
0
        /// <summary>
        /// Merge all error found in a validation dictionary to the current application message
        /// </summary>
        /// <param name="executionResult">instance of IApplicationMessage</param>
        /// <param name="validationDictionary">instance of IValidationDictionary</param>
        /// <param name="againstMessageCategory">add error message into this category</param>
        /// <returns>instance of application message in order to chain to other operations</returns>
        public static ExecutionResult Merge(this ExecutionResult executionResult, IValidationDictionary validationDictionary, MessageCategory againstMessageCategory = MessageCategory.BrokenBusinessRule)
        {
            if (executionResult == null) return null;

            if (validationDictionary != null)
            {

                validationDictionary
                    .Each(item => executionResult.Add(againstMessageCategory, new MessageGroup(item.Value.ToList())));
            }

            return executionResult;
        }
Пример #47
0
        public static bool IsValidUniversityEmail(string anEmail, IValidationDictionary aValidationDictionary)
        {
            IUniversityService theUniversityService = new UniversityService(aValidationDictionary);

            if (!theUniversityService.IsValidUniversityEmailAddress(anEmail)) {
                IEnumerable<string> myValidEmails = theUniversityService.ValidEmails();
                string myValidEmailsInString = string.Join(",", myValidEmails);

                aValidationDictionary.AddError("Email", anEmail, "I'm sorry that is not a valid University email. We currently only accept the following emails: " + myValidEmailsInString);
            }

            return aValidationDictionary.isValid;
        }
Пример #48
0
 public HAVProfileService(IValidationDictionary validationDictionary)
     : this(validationDictionary,
            new UserRetrievalService<User>(new EntityHAVUserRetrievalRepository()), 
            new FriendService<User, Friend>(new EntityHAVFriendRepository()),
            new PhotoAlbumService<User, PhotoAlbum, Photo, Friend>(validationDictionary, 
                new PhotoService<User, PhotoAlbum, Photo, Friend>(new FriendService<User, Friend>(new EntityHAVFriendRepository()), new EntityHAVPhotoAlbumRepository(), new EntityHAVPhotoRepository()),
                new FriendService<User, Friend>(new EntityHAVFriendRepository()),
                new EntityHAVPhotoAlbumRepository()),
            new EntityHAVProfileRepository(),
            new EntityHAVBoardRepository(),
            new ProfileQuestionService())
 {
 }
Пример #49
0
 public DataEntryService(IValidationDictionary validationDictionary, IUnitOfWork uow, int userKey)
 {
     _dataEntryDesignRepository      = uow.GetRepository <DataEntryDesign>();
     _dataEntryFieldRepository       = uow.GetRepository <DataEntryField>();
     _animalAdministrationRepository = uow.GetRepository <AnimalAdministration>();
     _procedureRepository            = uow.GetRepository <Procedure>();
     _administrationRepository       = uow.GetRepository <Administration>();
     _dataEntryRepository            = uow.DataEntryRepository;
     _animalRepository     = uow.GetRepository <Animal>();
     _userKey              = userKey;
     _fileService          = new FileService(validationDictionary, uow, userKey);
     _validationDictionary = validationDictionary;
 }
Пример #50
0
 public Manager_Service(IValidationDictionary validationDictionary, IProductRepository productrepository,
                        ISupplierRepository supplierrepository, IEmployeeRepository employeerepository,
                        ICategoryRepository categoryRepository,
                        IUserRepository userrepository
                        )
 {
     _validationDictionary = validationDictionary;
     _productrepository    = productrepository;
     _supplierrepository   = supplierrepository;
     _employeerepository   = employeerepository;
     _categoryrepository   = categoryRepository;
     _userrepository       = userrepository;
 }
        public bool Validate(object value,IValidationDictionary errorBag)
        {
            //if (errorBag == null) throw new ArgumentNullException("errorBag");

            foreach(var validator in _validators)
            {
                if (!validator.IsValid(value))
                {
                    if (errorBag!=null) errorBag.AddError(ReflectionInfo.Name,validator.FormatErrorMessage(ReflectionInfo.Name));
                    return false;
                }
            }
            return true;
        }
Пример #52
0
 public HAVProfileService(IValidationDictionary aValidationDictionary, 
                          IUserRetrievalService<User> aUserRetrievalService, 
                          IFriendService<User, Friend> aFriendService, 
                          IPhotoAlbumService<User, PhotoAlbum, Photo, Friend> aPhotoAlbumService, 
                          IHAVProfileRepository aRepository,
                          IBoardRepository<User, Board, BoardReply> aBoardRepository,
                          IProfileQuestionService aProfileQuestionService)
 {
     theValidationDictionary = aValidationDictionary;
     theUserRetrievalService = aUserRetrievalService;
     theFriendService = aFriendService;
     theRepository = aRepository;
     theBoardRepository = aBoardRepository;
     thePhotoAlbumService = aPhotoAlbumService;
     theProfileQuestionService = aProfileQuestionService;
 }
 public PrintController()
 {
     validationDictionary = new ModelStateWrapper(ModelState);
     _customResorces = new CustomResourcesService(validationDictionary);
 }
Пример #54
0
 public EventFlagService(IValidationDictionary validationDictionary)
     : this(validationDictionary, new EventFlagRepository())
 {
 }
Пример #55
0
 public EventFlagService(IValidationDictionary validationDictionary, IEventFlagRepository eventFlagRepository)
 {
     _validationDictionary = validationDictionary;
     _eventFlagRepository = eventFlagRepository;
 }
Пример #56
0
        public bool IsValid(IValidationDictionary validationDictionary)
        {
            // Required fields
            if (Title.IsNullEmptyOrWhitespace())
            {
                validationDictionary.AddError("Title", "Required field.");
            }

            if (CommentText.IsNullEmptyOrWhitespace())
            {
                validationDictionary.AddError("CommentText", "Required field.");
            }

            if (EmailOnReply && EmailAddress.IsNullEmptyOrWhitespace())
            {
                validationDictionary.AddError("EmailAddress", "Email Address required for reply notification");
            }

            // Regex patterns
            if (!EmailAddress.IsNullEmptyOrWhitespace() && !EmailAddress.IsEmailAddress())
            {
                validationDictionary.AddError("EmailAddress", "Must be a valid email address.");
            }

            if (!Website.IsNullEmptyOrWhitespace() && !Website.IsHttpUrl())
            {
                validationDictionary.AddError("Website", "Must be a valid URL (include http:// part, or leave blank).");
            }

            // Max length violations
            if((Title ?? "").Trim().Length > TitleMaxLength)
            {
                validationDictionary.AddError("Title", "Cannot be longer than " + TitleMaxLength + " characters.");
            }

            if ((YourName ?? "").Trim().Length > NameMaxLength)
            {
                validationDictionary.AddError("YourName", "Cannot be longer than " + NameMaxLength + " characters.");
            }

            if ((EmailAddress ?? "").Trim().Length > EmailAddressMaxLength)
            {
                validationDictionary.AddError("EmailAddress", "Cannot be longer than " + EmailAddressMaxLength + " characters.");
            }

            if ((Website ?? "").Trim().Length > WebsiteMaxLength)
            {
                validationDictionary.AddError("Website", "Cannot be longer than " + WebsiteMaxLength + " characters.");
            }

            if ((CommentText ?? "").Trim().Length > CommentTextMaxLength)
            {
                validationDictionary.AddError("CommentText", "Cannot be longer than " + CommentTextMaxLength + " characters.");
            }

            // Recaptcha
            if (!PassesCaptchaValidation)
            {
                validationDictionary.AddError("Captcha", "Failed Captcha test, please try again.");
            }

            return validationDictionary.IsValid;
        }
Пример #57
0
 public CityNameService(IValidationDictionary validationDictionary, ICityNameRepository cityNameRepository)
 {
     _validationDictionary = validationDictionary;
     _cityNameRepository = cityNameRepository;
 }
 public ServiceService(IValidationDictionary validationDictionary)
     : this(validationDictionary, new EntityServiceRepository(), new SystemServicesService(validationDictionary))
 {
 }
Пример #59
0
 public HAVFeedbackService(IValidationDictionary aValidationDictionary, IHAVFeedbackRepository aRepository)
 {
     theValidationDictionary = aValidationDictionary;
     theRepository = aRepository;
 }
Пример #60
0
 public HAVFeedbackService(IValidationDictionary aValidationDictionary)
     : this(aValidationDictionary, new EntityHAVFeedbackRepository())
 {
 }