コード例 #1
0
 public PostLogsController(HubDbContext dbContext,
                           ILogger <PostLogsController> logger,
                           IMapper mapper) : base(logger)
 {
     this.dbContext = dbContext;
     this.mapper    = mapper;
 }
コード例 #2
0
 public ActivitiesController(HubDbContext dbContext,
                             ILogger <ActivitiesController> logger,
                             IMapper mapper)
 {
     this.dbContext = dbContext;
     this.logger    = logger;
     this.mapper    = mapper;
 }
コード例 #3
0
 public SearchController(HubDbContext dbContext,
                         ILogger <SearchController> logger,
                         IMapper mapper)
 {
     this.dbContext = dbContext;
     this.logger    = logger;
     this.mapper    = mapper;
 }
コード例 #4
0
 public PostsController(HubDbContext dbContext,
                        ILogger <PostsController> logger,
                        IMapper mapper,
                        IWebHostEnvironment env) : base(logger)
 {
     this.dbContext    = dbContext;
     this.mapper       = mapper;
     this.isProduction = false;// env?.IsProduction() != false;
 }
コード例 #5
0
 public ActivitiesController(HubDbContext dbContext,
                             ILogger <ActivitiesController> logger,
                             IMapper mapper,
                             IHostEnvironment env) : base(logger)
 {
     this.dbContext = dbContext;
     this.mapper    = mapper;
     if (env?.IsProduction() == false && !mostFutureForecastActivity.HasValue)
     {
         mostFutureForecastActivity = Forecast(dbContext).Where(a => a.IsActive).OrderByDescending(a => a.StartDateTime).First().StartDateTime?.Date;
     }
 }
コード例 #6
0
 private IQueryable <Activity> Forecast(HubDbContext dbContext)
 {
     return(QueryAll(dbContext)
            .Where(a => a.IsConfirmed && !a.IsConfidential && a.ActivityKeywords.Any(ak => ak.Keyword.Name == "HQ-1P" || ak.Keyword.Name == "DB") ||
                   !a.IsConfirmed && !a.IsConfidential && a.StartDateTime.Value.Date == a.EndDateTime.Value.Date && !a.IsAllDay &&
                   a.ActivityKeywords.Any(ak => ak.Keyword.Name == "HQ-1P" || ak.Keyword.Name == "DB") ||
                   !a.IsConfirmed && !a.IsConfidential && a.StartDateTime.Value.Date == a.EndDateTime.Value.Date && a.IsAllDay &&
                   a.ActivityKeywords.Any(ak => ak.Keyword.Name == "HQ-1P" || ak.Keyword.Name == "DB") ||
                   a.IsConfirmed && a.IsConfidential && a.HqSection != 4 && a.ActivityKeywords.Any(ak => ak.Keyword.Name == "HQ-1P" || ak.Keyword.Name == "DB") ||
                   !a.IsConfirmed && a.IsConfidential && a.HqSection != 4 && a.StartDateTime.Value.Date == a.EndDateTime.Value.Date && !a.IsAllDay &&
                   a.ActivityKeywords.Any(ak => ak.Keyword.Name == "HQ-1P" || ak.Keyword.Name == "DB")));
 }
コード例 #7
0
        public bool Validate(MqttConnectionValidatorContext context)
        {
            var optionsBuilder = new DbContextOptionsBuilder <HubDbContext>();

            optionsBuilder.UseSqlServer(_configuration.GetConnectionString("HubDatabase"));
            HubUser user;

            using (var dbContext = new HubDbContext(optionsBuilder.Options))
            {
                user = dbContext.HubUser.SingleOrDefault(new Validator(context).Predicate);
            }

            return(user != null && "HUR-ACT" == user.StatusCode);
        }
コード例 #8
0
        public bool Validate(MqttConnectionValidatorContext context)
        {
            var optionsBuilder = new DbContextOptionsBuilder <HubDbContext>();

            optionsBuilder.UseSqlServer(_configuration.GetConnectionString("HubDatabase"));
            Agent agent;

            using (var dbContext = new HubDbContext(optionsBuilder.Options))
            {
                agent = dbContext.Agent.FirstOrDefault(new Validator(context).Predicate);
            }

            return(agent != null);
        }
コード例 #9
0
        public SocialMediaPostsControllerTests()
        {
            options = new DbContextOptionsBuilder <HubDbContext>()
                      .UseInMemoryDatabase(Guid.NewGuid().ToString())
                      .Options;
            context = new HubDbContext(options);
            logger  = new Mock <ILogger <SocialMediaPostsController> >();
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });

            mapper     = mockMapper.CreateMapper();
            controller = new SocialMediaPostsController(context, logger.Object, mapper);
        }
コード例 #10
0
        public ActivitiesControllerTests()
        {
            options = new DbContextOptionsBuilder <HubDbContext>()
                      .UseInMemoryDatabase(Guid.NewGuid().ToString())
                      .Options;
            context = new HubDbContext(this.options);

            logger = new Mock <ILogger <ActivitiesController> >();

            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });

            mapper = mockMapper.CreateMapper();
        }
コード例 #11
0
        public UserPreferencesControllerTests()
        {
            options = new DbContextOptionsBuilder <HubDbContext>()
                      .UseInMemoryDatabase(Guid.NewGuid().ToString())
                      .Options;
            context = new HubDbContext(options);
            logger  = new Mock <ILogger <UserPreferencesController> >();
            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });

            mapper = mockMapper.CreateMapper();

            httpContext       = new DefaultHttpContext();
            controllerContext = new ControllerContext()
            {
                HttpContext = httpContext,
            };
            var config = new ConfigurationBuilder().Build();

            controller = new UserPreferencesController(context, logger.Object, mapper, config);
            controller.ControllerContext = controllerContext;
        }
コード例 #12
0
        internal static void UpdateFromModel(this Activity dbActivity, Models.Activity activity, HubDbContext dbContext)
        {
            dbContext.Entry(dbActivity).CurrentValues.SetValues(activity);

            dbActivity.ContactMinistry = dbContext.Ministry.FirstOrDefault(m => m.Abbreviation == activity.ContactMinistryAbbreviation);

            if (activity.MinistriesSharedWith != null)
            {
                // This will also remove the unchecked ministries from dbActivity.ActivitySharedWith when the changed in the context are saved
                dbContext.ActivitySharedWith.RemoveRange(dbActivity.ActivitySharedWith.Where(m => !activity.MinistriesSharedWith.Contains(m.Ministry.Key)));

                foreach (var newMinistry in activity.MinistriesSharedWith.Where(sh => !dbActivity.ActivitySharedWith.Any(m => m.Ministry.Key == sh)))
                {
                    dbActivity.ActivitySharedWith.Add(new ActivitySharedWith {
                        Activity = dbActivity, Ministry = dbContext.Ministry.Single(m => m.Key == newMinistry)
                    });
                }
            }
            if (activity.Categories != null)
            {
                dbContext.ActivityCategories.RemoveRange(dbActivity.ActivityCategories.Where(ac => !activity.Categories.Contains(ac.Category.Name)));

                foreach (var newCategory in activity.Categories.Where(sh => !dbActivity.ActivityCategories.Any(ac => ac.Category.Name == sh)))
                {
                    dbActivity.ActivityCategories.Add(new ActivityCategories {
                        Activity = dbActivity, Category = dbContext.Category.Single(m => m.Name == newCategory)
                    });
                }
            }
            dbActivity.LastUpdatedDateTime = DateTime.Now;
        }
コード例 #13
0
 public CommentRepliesController(HubDbContext context)
 {
     _context = context;
 }
コード例 #14
0
 public CashPaymentsController(HubDbContext context)
 {
     _context = context;
 }
コード例 #15
0
 internal static IQueryable <Activity> QueryAll(HubDbContext dbContext)
 {
     return(dbContext.Activity.Include(a => a.ContactMinistry).Include(a => a.City)
            .Include(a => a.ActivityCategories).ThenInclude(ac => ac.Category)
            .Include(a => a.ActivitySharedWith).ThenInclude(sw => sw.Ministry));
 }
コード例 #16
0
 private ActivitiesController Controller(HubDbContext c = null)
 {
     return(new ActivitiesController(c ?? context, logger.Object, mapper, null));
 }
コード例 #17
0
 public UserDetailsController(HubDbContext context)
 {
     _context = context;
 }
コード例 #18
0
 public AnnualOrderDetailsController(HubDbContext context)
 {
     _context = context;
 }
コード例 #19
0
 public ShoppingCartsController(HubDbContext context)
 {
     _context = context;
 }
コード例 #20
0
 public OrgFeesController(HubDbContext context)
 {
     _context = context;
 }
コード例 #21
0
 public SocialMediaPostsController(HubDbContext dbContext, ILogger <SocialMediaPostsController> logger, IMapper mapper) : base(logger)
 {
     this.dbContext = dbContext;
     this.mapper    = mapper;
 }
コード例 #22
0
 public OrderHeadersController(HubDbContext context)
 {
     _context = context;
 }
コード例 #23
0
 public RatingsController(HubDbContext context)
 {
     _context = context;
 }
コード例 #24
0
 public AnnualsController(HubDbContext context)
 {
     _context = context;
 }
コード例 #25
0
 public WatchListsController(HubDbContext context)
 {
     _context = context;
 }
コード例 #26
0
 public UserPreferencesController(HubDbContext dbContext, ILogger <UserPreferencesController> logger, IMapper mapper, IConfiguration Configuration) : base(logger)
 {
     this.configuration = Configuration;
     this.dbContext     = dbContext;
     this.mapper        = mapper;
 }
コード例 #27
0
 public AdvsController(HubDbContext context)
 {
     _context = context;
 }
コード例 #28
0
 public NewsRegistersController(HubDbContext context)
 {
     _context = context;
 }
コード例 #29
0
 public EventApplyFormsController(HubDbContext context)
 {
     _context = context;
 }
コード例 #30
0
 public MinistriesController(HubDbContext dbContext, ILogger <MinistriesController> logger, IMapper mapper) : base(logger)
 {
     this.dbContext = dbContext;
     this.mapper    = mapper;
 }