Esempio n. 1
0
        public async Task <OutEmployeeViewModel?> GetEmployee(int id)
        {
            AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
            var emp = await _employeeService.GetEmployee(id, authorizedUserModel.Id);

            return(emp != null?_mapperProfile.Map <OutEmployeeViewModel>(emp) : null);
        }
Esempio n. 2
0
        public async Task <int> ChangeUserCredential([FromQuery] int categoryId, string login, string password)
        {
            AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
            var responce = await _contentService.ChangeUserCredential(authorizedUserModel.UserId, categoryId, login, password);

            return(1);
        }
        public async Task <OutQuizViewModel> Create([FromQuery] int id)
        {
            AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
            Quiz quiz = await _quizService.CreateNewQuiz(id, authorizedUserModel.Id);

            return(_mapperProfile.Map <OutQuizViewModel>(quiz));
        }
        public async Task <GroupResponseViewModel> GetGroup([FromRoute] int id)
        {
            AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
            var responce = await _groupService.GetGroup(id, authorizedUserModel.UserId);

            return(_mapperProfile.Map <GroupResponseViewModel>(responce));
        }
        public async Task <List <SourceResponseViewModel> > GroupSource([FromQuery] int groupId)
        {
            AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
            var responce = await _groupService.GroupSource(groupId, authorizedUserModel.UserId);

            return(_mapperProfile.Map <List <SourceResponseViewModel> >(responce));
        }
        public async Task <List <GroupResponseViewModel> > GetAllGroup()
        {
            AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
            var responce = await _groupService.GetAllGroups(authorizedUserModel.UserId);

            return(_mapperProfile.Map <List <GroupResponseViewModel> >(responce));
        }
        public async Task <List <CategoryResponseViewModel> > GetCategories()
        {
            AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
            var responce = await _categoryService.GetAllCategories(authorizedUserModel.UserId);

            return(_mapperProfile.Map <List <CategoryResponseViewModel> >(responce));
        }
        public async Task <List <OutQuizViewModel> > Get([FromQuery] int id)
        {
            AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
            List <Quiz>         quizzes             = await _quizService.GetEmployeeQuizzes(id, authorizedUserModel.Id);

            return(_mapperProfile.Map <List <OutQuizViewModel> >(quizzes));
        }
Esempio n. 9
0
        public async Task <OutEmployeeViewModel> AddEmployee(InEmployeeViewModel inEmployeeViewModel)
        {
            AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;

            Employee newEmp = _mapperProfile.Map <Employee>(inEmployeeViewModel);
            await _employeeService.AddEmployee(newEmp, authorizedUserModel.Id);

            return(_mapperProfile.Map <OutEmployeeViewModel>(newEmp));
        }
 public LoginController(UserManager <ApplicationUserEntity> userManager, IAuthenticationService authentificationService,
                        ApplicationDbContext entityContext, IFacebookAuthenticationService facebookAuthenticationService)
 {
     this.facebookAuthenticationService = facebookAuthenticationService;
     this.userManager           = userManager;
     this.authenticationService = authentificationService;
     this.entityContext         = entityContext;
     authorizedUserModel        = new AuthorizedUserModel();
 }
Esempio n. 11
0
        public async Task <OutEmployeeViewModel> EditEmployee(InEmployeeViewModel inEmployeeViewModel, int id)
        {
            AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;

            Employee emp       = _mapperProfile.Map <Employee>(inEmployeeViewModel);
            Employee editedEmp = await _employeeService.EditEmployee(emp, id, authorizedUserModel.Id);

            return(_mapperProfile.Map <OutEmployeeViewModel>(editedEmp));
        }
Esempio n. 12
0
 public FacebookAuthenticationService(IMapper mapper, ApplicationDbContext entityContext, UserManager <ApplicationUserEntity> userManager,
                                      IAuthenticationService authentificationService)
 {
     this.authentificationService = authentificationService;
     this.userManager             = userManager;
     this.entityContext           = entityContext;
     this.mapper         = mapper;
     httpClient          = new HttpClient();
     authorizedUserModel = new AuthorizedUserModel();
 }
Esempio n. 13
0
        public async Task <IActionResult> RequestMainMeetingRoomAccess()
        {
            bool grantAccess             = false;
            AuthorizedUserModel authUser = new AuthorizedUserModel(HttpContext.User);

            if (authUser != null && authUser.UserId > 0 && authUser.ProfileId > 0)
            {
                Door mainMeetingRoom = await _accessService.GetDoorByCompanyIdName(1, Misc.Enum.Door.MainMeetingRoom.ToString());

                grantAccess = await _accessService.GetProfileAccess(authUser.ProfileId, mainMeetingRoom.DoorId);

                _accessService.WriteAccessLog(grantAccess, mainMeetingRoom.DoorId, authUser.ProfileId, authUser.UserId);
            }
            if (grantAccess)
            {
                return(Ok());
            }
            return(Unauthorized());
        }
 public async Task DeleteCategory([FromRoute] int id)
 {
     AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
     await _categoryService.DeleteCategory(id, authorizedUserModel.UserId);
 }
 public async Task CreateCategory([FromQuery] string title)
 {
     AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
     await _categoryService.CreateCategory(title, authorizedUserModel.UserId);
 }
 public async Task DeleteSource([FromRoute] int id)
 {
     AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
     await _sourceService.DeleteSource(id, authorizedUserModel.UserId);
 }
        public async Task <int> CreateSource([FromQuery] string mediaUrl, int platformId)
        {
            AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;

            return(await _sourceService.CreateSource(Uri.UnescapeDataString(mediaUrl), platformId, authorizedUserModel.UserId));
        }
Esempio n. 18
0
 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     userSecurityContext = (AuthorizedUserModel)filterContext.HttpContext.Items["User"];
     _dataContext        = new DataContext(userSecurityContext.UserId);
     base.OnActionExecuting(filterContext);
 }
 public async Task CreateGroup([FromQuery] int categoryId, [FromQuery] int serialNumber)
 {
     AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
     await _groupService.CreateGroup(categoryId, serialNumber, authorizedUserModel.UserId);
 }
 public async Task AddSource([FromQuery] int groupId, [FromQuery] int sourceId)
 {
     AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
     await _groupService.AddSource(groupId, sourceId, authorizedUserModel.UserId);
 }
Esempio n. 21
0
 public AuthenticationService(UserManager <ApplicationUserEntity> userManager, IConfiguration configuration)
 {
     this.userManager    = userManager;
     this.configuration  = configuration;
     authorizedUserModel = new AuthorizedUserModel();
 }
 public async Task DeleteGroup([FromRoute] int groupId)
 {
     AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;
     await _groupService.DeleteGroup(groupId, authorizedUserModel.UserId);
 }
Esempio n. 23
0
        public async Task <List <OutEmployeeViewModel> > GetEmployees([FromQuery] int?quizStatusId = null, [FromQuery] bool?isCandidate = null)
        {
            AuthorizedUserModel authorizedUserModel = (AuthorizedUserModel)HttpContext.User.Identity;

            return(_mapperProfile.Map <List <OutEmployeeViewModel> >(await _employeeService.GetEmployees(authorizedUserModel.Id, quizStatusId, isCandidate)));
        }