Exemplo n.º 1
0
 public PostLogsController(HubDbContext dbContext,
                           ILogger <PostLogsController> logger,
                           IMapper mapper) : base(logger)
 {
     this.dbContext = dbContext;
     this.mapper    = mapper;
 }
 public ActivitiesController(HubDbContext dbContext,
                             ILogger <ActivitiesController> logger,
                             IMapper mapper)
 {
     this.dbContext = dbContext;
     this.logger    = logger;
     this.mapper    = mapper;
 }
Exemplo n.º 3
0
 public SearchController(HubDbContext dbContext,
                         ILogger <SearchController> logger,
                         IMapper mapper)
 {
     this.dbContext = dbContext;
     this.logger    = logger;
     this.mapper    = mapper;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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")));
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
        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);
        }
Exemplo n.º 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();
        }
        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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 13
0
 public CommentRepliesController(HubDbContext context)
 {
     _context = context;
 }
 public CashPaymentsController(HubDbContext context)
 {
     _context = context;
 }
Exemplo n.º 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));
 }
Exemplo n.º 16
0
 private ActivitiesController Controller(HubDbContext c = null)
 {
     return(new ActivitiesController(c ?? context, logger.Object, mapper, null));
 }
Exemplo n.º 17
0
 public UserDetailsController(HubDbContext context)
 {
     _context = context;
 }
 public AnnualOrderDetailsController(HubDbContext context)
 {
     _context = context;
 }
 public ShoppingCartsController(HubDbContext context)
 {
     _context = context;
 }
 public OrgFeesController(HubDbContext context)
 {
     _context = context;
 }
Exemplo n.º 21
0
 public SocialMediaPostsController(HubDbContext dbContext, ILogger <SocialMediaPostsController> logger, IMapper mapper) : base(logger)
 {
     this.dbContext = dbContext;
     this.mapper    = mapper;
 }
 public OrderHeadersController(HubDbContext context)
 {
     _context = context;
 }
Exemplo n.º 23
0
 public RatingsController(HubDbContext context)
 {
     _context = context;
 }
Exemplo n.º 24
0
 public AnnualsController(HubDbContext context)
 {
     _context = context;
 }
 public WatchListsController(HubDbContext context)
 {
     _context = context;
 }
Exemplo n.º 26
0
 public UserPreferencesController(HubDbContext dbContext, ILogger <UserPreferencesController> logger, IMapper mapper, IConfiguration Configuration) : base(logger)
 {
     this.configuration = Configuration;
     this.dbContext     = dbContext;
     this.mapper        = mapper;
 }
Exemplo n.º 27
0
 public AdvsController(HubDbContext context)
 {
     _context = context;
 }
Exemplo n.º 28
0
 public NewsRegistersController(HubDbContext context)
 {
     _context = context;
 }
 public EventApplyFormsController(HubDbContext context)
 {
     _context = context;
 }
Exemplo n.º 30
0
 public MinistriesController(HubDbContext dbContext, ILogger <MinistriesController> logger, IMapper mapper) : base(logger)
 {
     this.dbContext = dbContext;
     this.mapper    = mapper;
 }