コード例 #1
0
        public static async Task ValidateAsync(CookieValidatePrincipalContext context)
        {
            context = context ?? throw new ArgumentNullException(nameof(context));

            String username = context.Principal.Claims.FirstOrDefault(claim => claim.Type == ClaimTypes.Name)?.Value;

            if (username == null)
            {
                context.RejectPrincipal();
                await context.HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);

                return;
            }

            AfricanFarmerCommoditiesDBContext dbContext = context.HttpContext.RequestServices.GetRequiredService <AfricanFarmerCommoditiesDBContext>();
            User user = await dbContext.Users.FirstOrDefaultAsync(u => u.Username.ToLower().Equals(username.ToLower()));

            if (user == null)
            {
                context.RejectPrincipal();
                await context.HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);

                return;
            }
        }
コード例 #2
0
 public override bool Delete(Schedule toDelete)
 {
     try
     {
         toDelete = AfricanFarmerCommoditiesDBContext.Schedules.SingleOrDefault(p => p.ScheduleId == toDelete.ScheduleId);
         AfricanFarmerCommoditiesDBContext.Remove(toDelete);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
コード例 #3
0
 public override bool Delete(ActiveEnrouteCommodityMonitor toDelete)
 {
     try
     {
         toDelete = AfricanFarmerCommoditiesDBContext.ActiveEnrouteCommodityMonitors.SingleOrDefault(p => p.ActiveEnrouteCommodityMonitorId == toDelete.ActiveEnrouteCommodityMonitorId);
         AfricanFarmerCommoditiesDBContext.Remove(toDelete);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
コード例 #4
0
 public override bool Delete(CommodityCategory toDelete)
 {
     try
     {
         toDelete = AfricanFarmerCommoditiesDBContext.CommodityCategories.SingleOrDefault(p => p.CommodityCategoryId == toDelete.CommodityCategoryId);
         AfricanFarmerCommoditiesDBContext.Remove(toDelete);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
コード例 #5
0
 public override bool Delete(VehicleCapacity toDelete)
 {
     try
     {
         toDelete = AfricanFarmerCommoditiesDBContext.VehicleCapacities.SingleOrDefault(p => p.VehicleCapacityId == toDelete.VehicleCapacityId);
         AfricanFarmerCommoditiesDBContext.Remove(toDelete);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
コード例 #6
0
 public override bool Delete(FoodHubStorage toDelete)
 {
     try
     {
         toDelete = AfricanFarmerCommoditiesDBContext.FoodHubStorages.SingleOrDefault(p => p.FoodHubStorageId == toDelete.FoodHubStorageId);
         AfricanFarmerCommoditiesDBContext.Remove(toDelete);
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
コード例 #7
0
 public override bool Delete(TransportPricing toDelete)
 {
     try
     {
         toDelete = AfricanFarmerCommoditiesDBContext.TransportPricings.SingleOrDefault(p => p.TransportPricingId == toDelete.TransportPricingId);
         AfricanFarmerCommoditiesDBContext.Remove(toDelete);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
コード例 #8
0
 public AfricanFarmerCommoditiesUnitOfWork(
     AbstractRepository <Address> addressRepository,
     AbstractRepository <Driver> driverRepository,
     AbstractRepository <Invoice> invoiceRepository,
     AbstractRepository <Item> itemRepository,
     AbstractRepository <Itinary> itinaryRepository,
     AbstractRepository <Location> locationRepository,
     AbstractRepository <Schedule> scheduleRepository,
     AbstractRepository <Vehicle> vehicleRepository,
     AbstractRepository <SchedulesPricing> schedulesPricingRepository,
     AbstractRepository <DealsPricing> dealsPricingRepository,
     AbstractRepository <TransportPricing> transportPricingRepository,
     AbstractRepository <User> userRepository,
     AbstractRepository <Role> rolesRepository,
     AbstractRepository <UserRole> userInRolesRepository,
     AbstractRepository <VehicleCategory> vehicleCategoryRepository,
     AbstractRepository <FoodHubStorage> foodHubStorageRepository,
     AbstractRepository <VehicleCapacity> vehicleCapacityRepository,
     AbstractRepository <FoodHub> foodHubRepository,
     AbstractRepository <CommodityUnit> commodityUnitRepository,
     AbstractRepository <Commodity> commodityRepository,
     AbstractRepository <CommodityCategory> commodityCategoryRepository,
     AbstractRepository <ActiveEnrouteCommodityMonitor> activeEnrouteCommodityMonitorRepository,
     AbstractRepository <TransportSchedule> transportScheduleRepository,
     AbstractRepository <Company> companyRepository,
     AfricanFarmerCommoditiesDBContext africanFarmerCommoditiesDbContext)
 {
     AfricanFarmerCommoditiesDbContext = africanFarmerCommoditiesDbContext as AfricanFarmerCommoditiesDBContext;
     _addressRepository = addressRepository as AddressRepository;
     _addressRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _driverRepository = driverRepository as DriverRepository;
     _driverRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _invoiceRepository = invoiceRepository as InvoiceRepository;
     _invoiceRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _itemRepository = itemRepository as ItemRepository;
     _itemRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _itinaryRepository = itinaryRepository as ItinaryRepository;
     _itinaryRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _locationRepository = locationRepository as LocationRepository;
     _locationRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _scheduleRepository = scheduleRepository as ScheduleRepository;
     _scheduleRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _vehicleRepository = vehicleRepository as VehicleRepository;
     _vehicleRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _dealsPricingRepository = dealsPricingRepository as DealsPricingRepository;
     _dealsPricingRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _schedulesPricingRepository = schedulesPricingRepository as SchedulesPricingRepository;
     _schedulesPricingRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _userRepository = userRepository as UserRepository;
     _userRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _rolesRepository = rolesRepository as RolesRepository;
     _rolesRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _userInRolesRepository = userInRolesRepository as UserInRolesRepository;
     _userInRolesRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _transportPricingRepository = transportPricingRepository as TransportPricingRepository;
     _transportPricingRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _vehicleCategoryRepository = vehicleCategoryRepository as VehicleCategoryRepository;
     _vehicleCategoryRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _foodHubStorageRepository = foodHubStorageRepository as FoodHubStorageRepository;
     _foodHubStorageRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _foodHubRepository = foodHubRepository as FoodHubRepository;
     _foodHubRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _vehicleCapacityRepository = vehicleCapacityRepository as VehicleCapacityRepository;
     _vehicleCapacityRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _commodityUnitRepository = commodityUnitRepository as CommodityUnitRepository;
     _commodityUnitRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _commodityRepository = commodityRepository as CommodityRepository;
     _commodityRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _commodityCategoryRepository = commodityCategoryRepository as CommodityCategoryRepository;
     _commodityCategoryRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _activeEnrouteCommodityMonitorRepository = activeEnrouteCommodityMonitorRepository as ActiveEnrouteCommodityMonitorRepository;
     _activeEnrouteCommodityMonitorRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _transportScheduleRepostiory = transportScheduleRepository as TransportScheduleRepository;
     _transportScheduleRepostiory.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
     _companyRepository = companyRepository as CompanyRepository;
     _companyRepository.AfricanFarmerCommoditiesDBContext = africanFarmerCommoditiesDbContext;
 }