예제 #1
0
 static Program()
 {
     _listService = DependencyInjection.Setup().GetService <IListService>();
     numbers      = new List <long> {
         1, 2, 4, 5, 6, 7
     };
 }
예제 #2
0
        public BulkCreateValidator(ITaskService taskService, IListService listService)
        {
            RuleFor(dto => dto.UserId)
            .NotEmpty().WithMessage("Unauthorized")
            .Must((dto, userId) => listService.UserOwnsOrShares(dto.ListId, userId)).WithMessage("Unauthorized");

            RuleFor(dto => dto.ListId)
            .Must((dto, listId) =>
            {
                var taskNames = dto.TasksText.Split("\n").Where(x => !string.IsNullOrWhiteSpace(x));
                return(taskService.Count(listId) + taskNames.Count() <= 250);
            }).WithMessage("TasksPerListLimitReached");

            RuleFor(dto => dto.TasksText).NotEmpty().WithMessage("Tasks.BulkCreate.TextIsRequired").Must(tasksText =>
            {
                var tasks = tasksText.Split("\n").Where(x => !string.IsNullOrWhiteSpace(x));
                return(tasks.Any());
            }).WithMessage("Tasks.BulkCreate.NoTasks").Must((dto, tasksText) =>
            {
                IEnumerable <string> taskNames = tasksText.Split("\n").Where(x => !string.IsNullOrWhiteSpace(x));
                return(!taskService.Exists(taskNames, dto.ListId, dto.UserId));
            }).WithMessage("Tasks.BulkCreate.SomeTasksAlreadyExist").Must(tasksText =>
            {
                var tasks      = tasksText.Split("\n").Where(x => !string.IsNullOrWhiteSpace(x));
                var duplicates = tasks.GroupBy(x => x).Where(g => g.Count() > 1).Select(y => y.Key).ToList();
                return(!duplicates.Any());
            }).WithMessage("Tasks.BulkCreate.DuplicateTasks").Must(tasksText =>
            {
                var tasks = tasksText.Split("\n").Where(x => !string.IsNullOrWhiteSpace(x) && x.Length > 50);
                return(!tasks.Any());
            }).WithMessage("Tasks.BulkCreate.TasksNameMaxLength");
        }
예제 #3
0
        private void frmEmailCampaign_Load(object sender, EventArgs e)
        {
            try
            {
                string state = "ok";
                _accessToken = OAuth.AuthenticateFromWinProgram(ref state);

                if (string.IsNullOrEmpty(_accessToken))
                {
                    Application.Exit();
                }

                //initialize ConstantContact members
                IUserServiceContext    userServiceContext      = new UserServiceContext(_accessToken, _apiKey);
                ConstantContactFactory _constantContactFactory = new ConstantContactFactory(userServiceContext);
                _emailCampaignService         = _constantContactFactory.CreateEmailCampaignService();
                _emailCampaginScheduleService = _constantContactFactory.CreateCampaignScheduleService();
                _listService    = _constantContactFactory.CreateListService();
                _accountService = _constantContactFactory.CreateAccountService();
            }
            catch (OAuth2Exception oauthEx)
            {
                MessageBox.Show(string.Format("Authentication failure: {0}", oauthEx.Message), "Warning");
            }

            PopulateCampaignTypeList();
            PopulateListOfCountries();
            PopulateUSAndCanadaListOfStates();

            GetListOfContacts();
            PopulateEmailLists();
        }
        public UpdateTaskValidator(ITaskService taskService, IListService listService)
        {
            RuleFor(dto => dto.UserId)
            .NotEmpty().WithMessage("Unauthorized")
            .Must((dto, userId) => !taskService.Exists(dto.Id, dto.Name, dto.ListId, userId)).WithMessage("AlreadyExists");

            RuleFor(dto => dto.ListId)
            .MustAsync(async(dto, listId, val) =>
            {
                SimpleTask originalTask = await taskService.GetAsync(dto.Id);
                bool listChanged        = listId != originalTask.ListId;

                if (listChanged && taskService.Count(dto.ListId) == 250)
                {
                    return(false);
                }

                return(true);
            }).WithMessage("Tasks.UpdateTask.SelectedListAlreadyContainsMaxTasks");

            RuleFor(dto => dto.AssignedToUserId)
            .Must((dto, assignedToUserId) =>
            {
                if (dto.AssignedToUserId.HasValue && !listService.UserOwnsOrSharesAsPending(dto.ListId, assignedToUserId.Value))
                {
                    return(false);
                }

                return(true);
            }).WithMessage("Tasks.UpdateTask.TheAssignedUserIsNotAMember");

            RuleFor(dto => dto.Name)
            .NotEmpty().WithMessage("Tasks.ModifyTask.NameIsRequired")
            .MaximumLength(50).WithMessage("Tasks.ModifyTask.NameMaxLength");
        }
예제 #5
0
파일: Form1.cs 프로젝트: lokygb/.net-sdk
        private void frmEmailCampaign_Load(object sender, EventArgs e)
        {
            try
            {
                string state = "ok";
                _accessToken = OAuth.AuthenticateFromWinProgram(ref state);

                if (string.IsNullOrEmpty(_accessToken))
                {
                    Application.Exit();
                }

                //initialize ConstantContact members
                IUserServiceContext userServiceContext = new UserServiceContext(_accessToken, _apiKey);
                ConstantContactFactory _constantContactFactory = new ConstantContactFactory(userServiceContext);
                _emailCampaignService = _constantContactFactory.CreateEmailCampaignService();
                _emailCampaginScheduleService = _constantContactFactory.CreateCampaignScheduleService();
                _listService = _constantContactFactory.CreateListService();
                _accountService = _constantContactFactory.CreateAccountService();
            }
            catch (OAuth2Exception oauthEx)
            {
                MessageBox.Show(string.Format("Authentication failure: {0}", oauthEx.Message), "Warning");
            }

            PopulateCampaignTypeList();
            PopulateListOfCountries();
            PopulateUSAndCanadaListOfStates();

            GetListOfContacts();
            PopulateEmailLists();
        }
예제 #6
0
 public AccountController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IEventService events,
     IEmailTemplateService emailTemplateService,
     IAccountService accountService,
     IListService listService,
     IRecipeService recipeService,
     ICdnService cdnService,
     IHttpClientFactory httpClientFactory,
     IConfiguration configuration,
     IStringLocalizer <AccountController> localizer,
     IWebHostEnvironment webHostEnvironment,
     ILogger <AccountController> logger)
 {
     _userManager          = userManager;
     _signInManager        = signInManager;
     _interaction          = interaction;
     _clientStore          = clientStore;
     _events               = events;
     _emailTemplateService = emailTemplateService;
     _accountService       = accountService;
     _listService          = listService;
     _recipeService        = recipeService;
     _cdnService           = cdnService;
     _httpClientFactory    = httpClientFactory;
     _configuration        = configuration;
     _localizer            = localizer;
     _webHostEnvironment   = webHostEnvironment;
     _logger               = logger;
 }
예제 #7
0
 public ListController(
     IListService listService,
     IChannelService channelService)
 {
     _listService    = listService;
     _channelService = channelService;
 }
 public ListServicesTests()
 {
     _listService = DependencyInjection.Setup().GetService <IListService>();
     numbers      = new List <long> {
         1, 2, 4, 5, 6, 7
     };
 }
예제 #9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            _apiKey             = ConfigurationManager.AppSettings["APIKey"];
            Session["campaign"] = TextBox1.Text;
            try
            {
                string state = "ok";
                OAuth.AuthorizeFromWebApplication(HttpContext.Current
                                                  , state);


                //initialize ConstantContact members
                IUserServiceContext    userServiceContext      = new UserServiceContext(_accessToken, _apiKey);
                ConstantContactFactory _constantContactFactory = new ConstantContactFactory(userServiceContext);
                _emailCampaignService         = _constantContactFactory.CreateEmailCampaignService();
                _emailCampaginScheduleService = _constantContactFactory.CreateCampaignScheduleService();
                _listService    = _constantContactFactory.CreateListService();
                _accountService = _constantContactFactory.CreateAccountService();
            }
            catch (OAuth2Exception oauthEx)
            {
                //  MessageBox.Show(string.Format("Authentication failure: {0}", oauthEx.Message), "Warning");
            }


            //PopulateListOfCountries();
            //PopulateUSAndCanadaListOfStates();

            //GetListOfContacts();
            //PopulateEmailLists();
        }
예제 #10
0
        public ShareListValidator(IListService listService, IUserService userService)
        {
            RuleFor(dto => dto.UserId)
            .NotEmpty().WithMessage("Unauthorized")
            .Must((dto, userId) => listService.UserOwnsOrSharesAsAdmin(dto.ListId, userId)).WithMessage("Unauthorized");

            RuleForEach(dto => dto.NewShares).SetValidator(new ShareUserAndPermissionValidator(userService));
            RuleForEach(dto => dto.EditedShares).SetValidator(new ShareUserAndPermissionValidator(userService));
            RuleForEach(dto => dto.RemovedShares).SetValidator(new ShareUserAndPermissionValidator(userService));

            RuleFor(dto => dto).Must(dto =>
            {
                var userIds = dto.NewShares.Select(x => x.UserId)
                              .Concat(dto.EditedShares.Select(x => x.UserId))
                              .Concat(dto.RemovedShares.Select(x => x.UserId)).ToList();

                return(userIds.Count == userIds.Distinct().Count());
            }).WithMessage("AnErrorOccurred")
            .Must(dto =>
            {
                bool sharedWithCurrentUser = dto.NewShares.Any(x => x.UserId == dto.UserId) ||
                                             dto.EditedShares.Any(x => x.UserId == dto.UserId) ||
                                             dto.RemovedShares.Any(x => x.UserId == dto.UserId);

                return(!sharedWithCurrentUser);
            }).WithMessage("AnErrorOccurred");
        }
예제 #11
0
        // GET: Product
        public ActionResult Index(IListService service)
        {
            var dataForList = new ProductListSupportDataModel(ProductListFilters.AvailableForSale,
                                                              service.GetAll <ProductCategory>());

            return(View(dataForList));
        }
예제 #12
0
        private static CTCT.Components.Contacts.ContactList GetListByID(string p)
        {
            IUserServiceContext    userServiceContext = new UserServiceContext("3f09fe65-10ae-44a9-9db6-d9f2d6de1dec", "cvwkqk7ajrm67rcagvfwn9gx");
            ConstantContactFactory serviceFactory     = new ConstantContactFactory(userServiceContext);
            IListService           listService        = serviceFactory.CreateListService();

            try {
                ContactList lists = listService.GetList(p);

                if (lists != null)
                {
                    return(lists);
                }
            }

            catch (Exception ex)
            {
                CTCTLogger.LogFile(ex.InnerException.ToString(), ex.InnerException.ToString(), ex.Data.ToString(), (int)ex.LineNumber(), ex.Source.ToString());
                return(null);
            }



            return(null);
        }
 public ListsController(
     IListService listService,
     INotificationService notificationService,
     ISenderService senderService,
     IUserService userService,
     IValidator <CreateList> createValidator,
     IValidator <UpdateList> updateValidator,
     IValidator <UpdateSharedList> updateSharedValidator,
     IValidator <ShareList> shareValidator,
     IValidator <CopyList> copyValidator,
     IStringLocalizer <ListsController> localizer,
     IOptions <Urls> urls)
 {
     _listService           = listService;
     _notificationService   = notificationService;
     _senderService         = senderService;
     _userService           = userService;
     _createValidator       = createValidator;
     _updateValidator       = updateValidator;
     _updateSharedValidator = updateSharedValidator;
     _shareValidator        = shareValidator;
     _copyValidator         = copyValidator;
     _localizer             = localizer;
     _urls = urls.Value;
 }
예제 #14
0
 public ListController(ListNestDbContext dbContext,
                       IMapper mapper,
                       IListService listService)
 {
     _dbContext   = dbContext;
     _mapper      = mapper;
     _listService = listService;
 }
예제 #15
0
 public AllServiceBase(string url, ResponseToken token, string endpoint) : base(url, token, endpoint)
 {
     this.ListService   = new ListServiceBase <TResponse>(url, token, endpoint);
     this.DeleteService = new DeleteServiceBase <TResponse>(url, token, endpoint);
     this.GetService    = new GetServiceBase <TResponse>(url, token, endpoint);
     this.CreateService = new CreateServiceBase <TRequest, TResponse>(url, token, endpoint);
     this.UpdateService = new UpdateServiceBase <TRequest, TResponse>(url, token, endpoint);
 }
예제 #16
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="cacheRepository"></param>
 /// <param name="profileLogic"></param>
 /// <param name="elRepo"></param>
 public CacheController(ICacheRefreshRepository cacheRepository, IUserProfileLogic profileLogic, IEventLogRepository elRepo,
                        IListService listService, ICacheListLogic cacheListLogic) : base(profileLogic)
 {
     this.cacheRepository = cacheRepository;
     _listService         = listService;
     _cacheListLogic      = cacheListLogic;
     this._elRepo         = elRepo;
 }
예제 #17
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="profileLogic"></param>
 /// <param name="listService"></param>
 public IntegrationsController(
     IUserProfileLogic profileLogic,
     IListService listService
     ) : base(profileLogic)
 {
     _profileLogic = profileLogic;
     _listService  = listService;
 }
예제 #18
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="listServiceRepository"></param>
 /// <param name="profileLogic"></param>
 /// <param name="logRepo"></param>
 public ItemNoteController(IListLogic listServiceRepository, IUserProfileLogic profileLogic, INotesListLogic notesLogic,
                           IEventLogRepository logRepo, IListService listService) : base(profileLogic)
 {
     this.listServiceRepository = listServiceRepository;
     _notesLogic  = notesLogic;
     _listService = listService;
     _log         = logRepo;
 }
예제 #19
0
        public override void InitHelpers()
        {
            base.InitHelpers();

            var controller = (ViewContext.Controller as BaseController);

            ListService = controller.ListService;
        }
        public JsonResult GetCompanies(string text, IListService service)
        {
            var companies = service.GetAll <ListCustomerDto>();

            return(string.IsNullOrEmpty(text)
                ? Json(companies, JsonRequestBehavior.AllowGet)
                : Json(companies.Where(p => p.CompanyName.Contains(text)), JsonRequestBehavior.AllowGet));
        }
예제 #21
0
 public ListItemController(IWorkContextAccessor workContextAccessor, IListItemService listItemService, IListFieldService listFieldService, IListService listService, IListCategoryService listCategoryService)
     : base(workContextAccessor)
 {
     this.listItemService     = listItemService;
     this.listFieldService    = listFieldService;
     this.listService         = listService;
     this.listCategoryService = listCategoryService;
 }
예제 #22
0
 public ListController(ILogger <ListController> logger
                       , ISystemClockService systemClock
                       , IListService listService)
 {
     _logger      = logger;
     _systemClock = systemClock;
     _listService = listService;
 }
예제 #23
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="listLogic"></param>
 /// <param name="profileLogic"></param>
 /// <param name="logRepo"></param>
 public RecentItemController(IListLogic listLogic, IUserProfileLogic profileLogic, IRecentlyViewedListLogic recentlyViewedLogic,
                             IRecentlyOrderedListLogic recentlyOrderedLogic, IListService listService, IEventLogRepository logRepo)  : base(profileLogic)
 {
     _repo = listLogic;
     _recentlyViewedLogic  = recentlyViewedLogic;
     _recentlyOrderedLogic = recentlyOrderedLogic;
     _listService          = listService;
     _log = logRepo;
 }
 public TaskService(
     ITasksRepository tasksRepository,
     IListService listService,
     IMapper mapper)
 {
     _tasksRepository = tasksRepository;
     _listService     = listService;
     _mapper          = mapper;
 }
예제 #25
0
 public TaskService(
     IRepositoryService repositoryService,
     IObjectMapper objectMapper,
     IListService <TaskViewModel> listService)
 {
     this.repositoryService = repositoryService;
     this.objectMapper      = objectMapper;
     this.listService       = listService;
 }
 public MaintenanceHostedService(
     IChannelService channelService,
     IListService listService,
     ILogger <MaintenanceHostedService> logger)
 {
     _channelService = channelService;
     _listService    = listService;
     _logger         = logger;
 }
예제 #27
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="randomizeService">Randomization service</param>
        /// <param name="listService">List Service</param>
        public BasicRandomVM(IRandomizeService randomizeService, IListService listService)
        {
            // Services Interfaces
            _randomizeService = randomizeService;
            _listService      = listService;

            // List Init
            ItemsList = new ObservableCollection <string>();
        }
예제 #28
0
 public ListViewModel()
 {
     CleanUp();
     _listService = new ListService();
     Messenger.Default.Register <ListTypes>(this, message =>
     {
         ListType = message;
     });
 }
예제 #29
0
 public DashboardController(IUserService userService, IBoardService boardService, IListService listService, ICardService cardService, ICardCommentService cardCommentService, IMapper mapper)
 {
     _userService        = userService;
     _boardService       = boardService;
     _listService        = listService;
     _cardService        = cardService;
     _cardCommentService = cardCommentService;
     _mapper             = mapper;
 }
예제 #30
0
 public AssignmentService(
     DbContext context,
     IObjectMapper mapper,
     IListService <AssignmentViewModel> listService)
 {
     this.context     = context;
     this.mapper      = mapper;
     this.listService = listService;
 }
예제 #31
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            // Register dependencies
            var dependencyFactory = new DependencyFactory();

            // Initialize database
            //  On the first run creates database and tables and adds default tables
            InitializeDatabase();

            // Load base models used in the application
            ISyncService syncService = DependencyFactory.Resolve <ISyncService>();
            IListService listService = DependencyFactory.Resolve <IListService>();
            ITaskService taskService = DependencyFactory.Resolve <ITaskService>();

            // load  model for main view
            AppListsModel = new ListViewModel(syncService, listService);
            AppTasksModel = new TaskViewModel(syncService, taskService);

            syncService.Start();

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
        //-----------------------------------------------
        public JsonResult GetProducts(string text, IListService service)
        {
            var products =
                service.GetAll<Product>()
                    .Select(x => new KeyTextClass<int> {Key = x.ProductID, Text = x.ProductNumber + " (" + x.ProductCategory.Name + ", " + x.Name + ")"});

            return string.IsNullOrEmpty(text)
                ? Json(products, JsonRequestBehavior.AllowGet)
                : Json(products.Where(p => p.Text.Contains(text)), JsonRequestBehavior.AllowGet);
        }
 // GET: TagsAsync
 public async Task<ActionResult> Index(IListService service)
 {
     return View(await service.GetAll<TagListDto>().ToListAsync());
 }
 public JsonResult IndexListRead([DataSourceRequest]DataSourceRequest request, IListService service)
 {
     var result = service.GetAll<ListProductDto>().OrderBy( x => x.ProductID).ToDataSourceResult(request);
     return Json(result);
 }
 // GET: Product
 public ActionResult Index(IListService service)
 {
     var dataForList = new ProductListSupportDataModel(ProductListFilters.AvailableForSale,
         service.GetAll<ProductCategory>());
     return View(dataForList);
 }
 /// <summary>
 /// reads only the SalesOrderDetail for the given sales order
 /// </summary>
 /// <param name="request"></param>
 /// <param name="salesOrderId"></param>
 /// <param name="service"></param>
 /// <returns></returns>
 public JsonResult ReadLineItems([DataSourceRequest]DataSourceRequest request, int salesOrderId, IListService service)
 {
     var result = service.GetAll<CrudSalesOrderDetailDto>().Where(x => x.SalesOrderID == salesOrderId).OrderBy(x => x.SalesOrderDetailID).ToDataSourceResult(request);
     return Json(result);
 }
 public RoomRepository(IListService<Room> listService)
 {
     this.listService = listService;
 }
예제 #38
0
        /// <summary>
        /// Note that is Index is different in that it has an optional id to filter the list on.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        public ActionResult Index(int? id, IListService service)
        {
            var filtered = id != null && id != 0;
            var query = filtered ? service.GetAll<SimplePostDto>().Where(x => x.BlogId == id) : service.GetAll<SimplePostDto>();
            if (filtered)
                TempData["message"] = "Filtered list";

            return View(query.ToList());
        }
예제 #39
0
 public ActionResult Index(IListService service)
 {
     return View(service.GetAll<BlogListDto>().ToList());
 }
 public SimpleAssetRepository(IListService<Asset> listService)
 {
     this.listService = listService;
 }
예제 #41
0
 public HomeController()
 {
     _listService = new ListService();
     _sessionContext = SessionContext.Current;
 }
예제 #42
0
 public HomeController(IListService listService, ISessionContext sessionContext)
 {
     _listService = listService;
     _sessionContext = sessionContext;
 }
 public UOWAssetRepository(IListService<Asset> listService, IUnitOfWork<Asset> unitOfWork)
 {
     this.listService = listService;
     this.unitOfWork = unitOfWork;
 }
        public JsonResult GetCompanies(string text, IListService service)
        {
            var companies = service.GetAll<ListCustomerDto>();

            return string.IsNullOrEmpty(text)
                ? Json(companies, JsonRequestBehavior.AllowGet)
                : Json(companies.Where(p => p.CompanyName.Contains(text)), JsonRequestBehavior.AllowGet);
        }
 public JsonResult IndexListReadVer2([DataSourceRequest]DataSourceRequest request, IListService service)
 {
     var result = service.GetAll<ListCustomerVer2Dto>().OrderBy(x => x.CustomerID).ToDataSourceResult(request);
     return Json(result, JsonRequestBehavior.AllowGet);
 }
 public ActionResult AjaxProductDescriptionRead([DataSourceRequest]DataSourceRequest request, IListService service)
 {
     return Json(service.GetAll<ProductDescription>().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
 }
예제 #47
0
 public PersonalController(IListService listService, ISessionContext sessionContext)
 {
     _listService = listService;
     _sessionContext = sessionContext;
 }