public ManageController(
            IUnitOfWorkAsync unitOfWorkAsync,
            ISettingService settingService,
            ICategoryService categoryService,
            IListingService listingService,
            IPictureService pictureService,
            IListingPictureService ListingPictureservice,
            IOrderService orderService,
            ICustomFieldService customFieldService,
            ICustomFieldCategoryService customFieldCategoryService,
            ICustomFieldListingService customFieldListingService,
            ISettingDictionaryService settingDictionaryService,
            IListingStatService ListingStatservice,
            DataCacheService dataCacheService,
            SqlDbService sqlDbService)
        {
            _settingService           = settingService;
            _settingDictionaryService = settingDictionaryService;

            _categoryService       = categoryService;
            _listingService        = listingService;
            _pictureService        = pictureService;
            _ListingPictureservice = ListingPictureservice;
            _orderService          = orderService;

            _customFieldService         = customFieldService;
            _customFieldCategoryService = customFieldCategoryService;
            _customFieldListingService  = customFieldListingService;
            _ListingStatservice         = ListingStatservice;

            _dataCacheService = dataCacheService;
            _sqlDbService     = sqlDbService;

            _unitOfWorkAsync = unitOfWorkAsync;
        }
Esempio n. 2
0
        public ManageController(
            IUnitOfWorkAsync unitOfWorkAsync,
            ISettingService settingService,
            ICategoryService categoryService,
            IListingService listingService,
            ICustomFieldService customFieldService,
            ICustomFieldCategoryService customFieldCategoryService,
            IContentPageService contentPageService,
            IOrderService orderService,
            ISettingDictionaryService settingDictionaryService,
            IEmailTemplateService emailTemplateService,
            DataCacheService dataCacheService,
            SqlDbService sqlDbService,
            IPluginFinder pluginFinder)
        {
            _settingService           = settingService;
            _settingDictionaryService = settingDictionaryService;

            _categoryService            = categoryService;
            _listingService             = listingService;
            _customFieldService         = customFieldService;
            _customFieldCategoryService = customFieldCategoryService;

            _orderService = orderService;

            _emailTemplateService = emailTemplateService;
            _contentPageService   = contentPageService;
            _unitOfWorkAsync      = unitOfWorkAsync;
            _dataCacheService     = dataCacheService;
            _sqlDbService         = sqlDbService;
            _pluginFinder         = pluginFinder;
        }
        public ListingController(
            IUnitOfWorkAsync unitOfWorkAsync,
            ISettingService settingService,
            ICategoryService categoryService,
            ICategoryListingTypeService categoryListingTypeService,
            IListingService listingService,
            IListingTypeService listingTypeService,
            ICustomFieldService customFieldService,
            ICustomFieldCategoryService customFieldCategoryService,
            ICustomFieldListingService customFieldListingService,
            IContentPageService contentPageService,
            IOrderService orderService,
            IDetailBedService detailBedService,
            ITypeOfBedService typeOfBedService,
            ISettingDictionaryService settingDictionaryService,
            IEmailTemplateService emailTemplateService,
            IPictureService pictureService,
            IListingPictureService listingPictureservice,
            IListingReviewService listingReviewService,
            DataCacheService dataCacheService,
            SqlDbService sqlDbService,
            AspNetUserService aspNetUserService,
            IListingObservationService listingObservationService)
        {
            _settingService           = settingService;
            _settingDictionaryService = settingDictionaryService;

            _categoryService            = categoryService;
            _categoryListingTypeService = categoryListingTypeService;

            _listingService     = listingService;
            _listingTypeService = listingTypeService;

            _pictureService = pictureService;

            _listingPictureservice = listingPictureservice;
            _listingReviewService  = listingReviewService;

            _customFieldService         = customFieldService;
            _customFieldCategoryService = customFieldCategoryService;
            _customFieldListingService  = customFieldListingService;

            _orderService = orderService;

            _emailTemplateService      = emailTemplateService;
            _contentPageService        = contentPageService;
            _unitOfWorkAsync           = unitOfWorkAsync;
            _dataCacheService          = dataCacheService;
            _detailBedService          = detailBedService;
            _typeOfBedService          = typeOfBedService;
            _sqlDbService              = sqlDbService;
            _aspNetUserService         = aspNetUserService;
            _listingObservationService = listingObservationService;
        }
Esempio n. 4
0
 public AdvertisementController(IMessageService messageService, IManufacturerService manufacturerService, IModelService modelService, IUnitOfWorkAsync unitOfWorkAsync, IAdvertisementService advertisementService, IUserNotificationService userNotificationService, IFollowingService followingService, IFeatureService featureService, SqlDbService sqlDbService)
 {
     _manufacturerService     = manufacturerService;
     _modelService            = modelService;
     _advertisementService    = advertisementService;
     _followingService        = followingService;
     _featureService          = featureService;
     _sqlDbService            = sqlDbService;
     _userNotificationService = userNotificationService;
     _messageService          = messageService;
     _unitOfWorkAsync         = unitOfWorkAsync;
 }
Esempio n. 5
0
        public ManageController(
            IUnitOfWorkAsync unitOfWorkAsync,
            ISettingService settingService,
            ICategoryService categoryService,
            IListingService listingService,
            IPictureService pictureService,
            IListingPictureService ListingPictureservice,
            IOrderService orderService,
            ICustomFieldService customFieldService,
            ICustomFieldCategoryService customFieldCategoryService,
            ICustomFieldListingService customFieldListingService,
            ISettingDictionaryService settingDictionaryService,
            IListingStatService listingStatservice,
            IMessageService messageService,
            IMessageThreadService messageThreadService,
            IMessageParticipantService messageParticipantService,
            IMessageReadStateService messageReadStateService,
            DataCacheService dataCacheService,
            SqlDbService sqlDbService,


            IOrderBuyCoinService orderBuyCoinService
            )
        {
            _settingService           = settingService;
            _settingDictionaryService = settingDictionaryService;

            _categoryService       = categoryService;
            _listingService        = listingService;
            _pictureService        = pictureService;
            _ListingPictureservice = ListingPictureservice;
            _orderService          = orderService;

            //order buy coins
            _orderBuyCoinsService = orderBuyCoinService;

            _messageService            = messageService;
            _messageThreadService      = messageThreadService;
            _messageParticipantService = messageParticipantService;
            _messageReadStateService   = messageReadStateService;

            _customFieldService         = customFieldService;
            _customFieldCategoryService = customFieldCategoryService;
            _customFieldListingService  = customFieldListingService;
            _listingStatservice         = listingStatservice;

            _dataCacheService = dataCacheService;
            _sqlDbService     = sqlDbService;

            _unitOfWorkAsync = unitOfWorkAsync;
        }
        public PaymentController(
            IUnitOfWorkAsync unitOfWorkAsync,
            ISettingService settingService,
            ICategoryService categoryService,
            IListingService listingService,
            IPictureService pictureService,
            IListingPictureService ListingPictureservice,
            IOrderService orderService,
            ICustomFieldService customFieldService,
            ICustomFieldCategoryService customFieldCategoryService,
            ICustomFieldListingService customFieldListingService,
            ISettingDictionaryService settingDictionaryService,
            IListingStatService listingStatservice,
            IListingReviewService listingReviewService,
            DataCacheService dataCacheService,
            SqlDbService sqlDbService,
            IEmailTemplateService emailTemplateService,
            IPluginFinder pluginFinder,
            IAspNetUserService aspNetUserService,
            IAspNetRoleService aspNetRoleService,
            IDetailBedService detailBedService,
            IListingPriceService listingPriceService)
        {
            _settingService           = settingService;
            _settingDictionaryService = settingDictionaryService;

            _categoryService = categoryService;

            _listingService        = listingService;
            _pictureService        = pictureService;
            _listingPictureservice = ListingPictureservice;
            _listingStatservice    = listingStatservice;
            _listingReviewService  = listingReviewService;
            _detailBedService      = detailBedService;

            _orderService               = orderService;
            _customFieldService         = customFieldService;
            _customFieldCategoryService = customFieldCategoryService;
            _customFieldListingService  = customFieldListingService;
            _aspNetUserService          = aspNetUserService;
            _aspNetRoleService          = aspNetRoleService;

            _dataCacheService = dataCacheService;
            _sqlDbService     = sqlDbService;

            _pluginFinder = pluginFinder;

            _unitOfWorkAsync      = unitOfWorkAsync;
            _emailTemplateService = emailTemplateService;
            _listingPriceService  = listingPriceService;
        }
Esempio n. 7
0
        public ListingController(
            IUnitOfWorkAsync unitOfWorkAsync,
            ISettingService settingService,
            ICategoryService categoryService,
            IListingService listingService,
            IPictureService pictureService,
            IListingPictureService listingPictureservice,
            IOrderService orderService,
            IDetailBedService detailBedService,
            ITypeOfBedService typeOfBedService,
            ICustomFieldService customFieldService,
            ICustomFieldCategoryService customFieldCategoryService,
            ICustomFieldListingService customFieldListingService,
            ISettingDictionaryService settingDictionaryService,
            IListingStatService listingStatservice,
            IListingReviewService listingReviewService,
            IEmailTemplateService emailTemplateService,
            IMessageService messageService,
            IMessageThreadService messageThreadService,
            IMessageParticipantService messageParticipantService,
            IMessageReadStateService messageReadStateService,
            DataCacheService dataCacheService,
            SqlDbService sqlDbService,
            AspNetUserService aspNerUserService)
        {
            _settingService           = settingService;
            _settingDictionaryService = settingDictionaryService;

            _categoryService            = categoryService;
            _listingService             = listingService;
            _listingReviewService       = listingReviewService;
            _pictureService             = pictureService;
            _listingPictureservice      = listingPictureservice;
            _orderService               = orderService;
            _customFieldService         = customFieldService;
            _customFieldCategoryService = customFieldCategoryService;
            _customFieldListingService  = customFieldListingService;
            _ListingStatservice         = listingStatservice;
            _emailTemplateService       = emailTemplateService;
            _messageService             = messageService;
            _messageParticipantService  = messageParticipantService;
            _messageReadStateService    = messageReadStateService;
            _messageThreadService       = messageThreadService;
            _dataCacheService           = dataCacheService;
            _sqlDbService               = sqlDbService;
            _detailBedService           = detailBedService;
            _typeOfBedService           = typeOfBedService;
            _unitOfWorkAsync            = unitOfWorkAsync;
            _aspNetUserService          = aspNerUserService;
        }
Esempio n. 8
0
        public IActionResult RegisterAccount(Student student)
        {
            var salt = BasicAuthHandler.CreateSalt();

            var hash = BasicAuthHandler.CreatePass(student.password, salt);


            if (SqlDbService.RegisterAccount(student, salt, hash))
            {
                return(Ok());
            }

            return(StatusCode(403, "Couldn't create account"));
        }
Esempio n. 9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMiddleware <LoggingMiddleware>();

            app.Use(async(context, next) =>
            {
                if (!context.Request.Headers.ContainsKey("Index"))
                {
                    context.Response.StatusCode = StatusCodes.Status401Unauthorized;
                    await context.Response.WriteAsync("Nie podano indexu w naglowku");
                    return;
                }

                var index = context.Request.Headers["Index"].ToString();

                if (SqlDbService.CheckIndex(index))
                {
                    await next();
                }
                else
                {
                    context.Response.StatusCode = StatusCodes.Status401Unauthorized;
                    await context.Response.WriteAsync("Niepoprawny index studenta");
                    return;
                }
            });

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();



            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Esempio n. 10
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, SqlDbService service)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Student API V1");
            });

            // Request -> Index: s1234
            app.UseMiddleware <ExceptionMiddleware>();

            app.UseMiddleware <CustomLoggingMiddleware>();

            //Inline middleware (conditional)
            app.Use(async(context, next) =>
            {
                if (!context.Request.Headers.ContainsKey("index"))
                {
                    context.Response.StatusCode = StatusCodes.Status401Unauthorized;
                    await context.Response.WriteAsync("There was no index");
                    return;
                }
                var index = context.Request.Headers["Index"].ToString();
                if (!service.exists(index))
                {
                    await context.Response.WriteAsync("student with provided index number doesn't exist");
                }
                await next(); //calls the next middleware
            });

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Esempio n. 11
0
        public ListingController(
            IUnitOfWorkAsync unitOfWorkAsync,
            ISettingService settingService,
            ICategoryService categoryService,
            ICategoryListingTypeService categoryListingTypeService,
            IListingService listingService,
            IListingTypeService ListingTypeService,
            ICustomFieldService customFieldService,
            ICustomFieldCategoryService customFieldCategoryService,
            ICustomFieldListingService customFieldListingService,
            IContentPageService contentPageService,
            IOrderService orderService,
            ISettingDictionaryService settingDictionaryService,
            IEmailTemplateService emailTemplateService,
            IPictureService pictureService,
            IListingPictureService ListingPictureservice,
            DataCacheService dataCacheService,
            SqlDbService sqlDbService)
        {
            _settingService           = settingService;
            _settingDictionaryService = settingDictionaryService;

            _categoryService            = categoryService;
            _categoryListingTypeService = categoryListingTypeService;

            _listingService     = listingService;
            _ListingTypeService = ListingTypeService;

            _pictureService        = pictureService;
            _ListingPictureservice = ListingPictureservice;

            _customFieldService         = customFieldService;
            _customFieldCategoryService = customFieldCategoryService;
            _customFieldListingService  = customFieldListingService;

            _orderService = orderService;

            _emailTemplateService = emailTemplateService;
            _contentPageService   = contentPageService;
            _unitOfWorkAsync      = unitOfWorkAsync;
            _dataCacheService     = dataCacheService;
            _sqlDbService         = sqlDbService;
        }
Esempio n. 12
0
        public IActionResult Login(LoginRequestDto request)
        {
            if (!SqlDbService.CheckStudent(request))
            {
                return(StatusCode(403, "Login and password doesn't match"));
            }

            var claims = new[]
            {
                new Claim(ClaimTypes.NameIdentifier, "1"),
                new Claim(ClaimTypes.Name, "login"),
                new Claim(ClaimTypes.Role, "admin"),
                new Claim(ClaimTypes.Role, "student"),
                new Claim(ClaimTypes.Role, "employee")
            };

            var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["SecretKey"]));

            var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);

            var token = new JwtSecurityToken
                        (
                issuer: "Kacpi",
                audience: "Students",
                claims: claims,
                expires: DateTime.Now.AddMinutes(10),
                signingCredentials: creds
                        );
            var rt = Guid.NewGuid();

            if (!SqlDbService.SaveRefreshToken(request.Login, rt))
            {
                return(StatusCode(400, "Couldn't save refresh token!"));
            }
            ;
            return(Ok(new
            {
                token = new JwtSecurityTokenHandler().WriteToken(token),
                refreshToken = rt
            }));
        }
Esempio n. 13
0
        public IActionResult Login(LoginRequest request)
        {
            if (!SqlDbService.validReq(request))
            {
                return(Unauthorized());
            }

            var claims = new[]
            {
                new Claim(ClaimTypes.NameIdentifier, "1"),
                new Claim(ClaimTypes.Name, "login"),
                new Claim(ClaimTypes.Role, "admin"),
                new Claim(ClaimTypes.Role, "student"),
                new Claim(ClaimTypes.Role, "employee")
            };

            var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["SecretKey"]));

            var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);

            var token = new JwtSecurityToken
                        (
                issuer: "s18533",
                audience: "Students",
                claims: claims,
                expires: DateTime.Now.AddMinutes(10),
                signingCredentials: creds
                        );

            var refToken = Guid.NewGuid();

            _dbService.AddRefreshToken(refToken, request.indexNum);

            return(Ok(new
            {
                token = new JwtSecurityTokenHandler().WriteToken(token),
                refreshToken = refToken
            }));
        }
Esempio n. 14
0
        public IActionResult RefreshToken(string Rtoken)
        {
            var rtk      = System.Guid.Parse(Rtoken);
            var newToken = SqlDbService.CheckRefreshToken(rtk);

            if (newToken == null)
            {
                return(StatusCode(403, "Wrong refresh-token"));
            }

            var claims = new[]
            {
                new Claim(ClaimTypes.NameIdentifier, "1"),
                new Claim(ClaimTypes.Name, "login"),
                new Claim(ClaimTypes.Role, "admin"),
                new Claim(ClaimTypes.Role, "student"),
                new Claim(ClaimTypes.Role, "employee")
            };

            var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["SecretKey"]));

            var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);

            var token = new JwtSecurityToken
                        (
                issuer: "Kacpi",
                audience: "Students",
                claims: claims,
                expires: DateTime.Now.AddMinutes(10),
                signingCredentials: creds
                        );
            var rt = newToken;

            return(Ok(new
            {
                token = new JwtSecurityTokenHandler().WriteToken(token),
                refreshToken = rt
            }));
        }
Esempio n. 15
0
 public ManufacturerController(IManufacturerService manufacturerService, IUnitOfWorkAsync unitOfWorkAsync, SqlDbService sqlDbService)
 {
     _sqlDbService = sqlDbService;
 }
Esempio n. 16
0
 public NotificationsController(SqlDbService sqlDbService)
 {
     _sqlDbService = sqlDbService;
 }
Esempio n. 17
0
 public AcceptOrderFunction(SqlDbService sqlDbService)
 {
     _sqlDbService = sqlDbService;
 }
Esempio n. 18
0
 public FollowingController(SqlDbService sqlDbService)
 {
     _sqlDbService = sqlDbService;
 }
Esempio n. 19
0
 public FeatureController(IFeatureService featureService, IUnitOfWorkAsync unitOfWorkAsync, SqlDbService sqlDbService)
 {
     _featureService  = featureService;
     _unitOfWorkAsync = unitOfWorkAsync;
     _sqlDbService    = sqlDbService;
 }