Esempio n. 1
0
        public void Map_admin_persistance_to_admin_entity_when_persistance_is_null()
        {
            AdminPersistence adminPersistance = null;

            Assert.Throws <ArgumentNullException>(()
                                                  => AdminMapper.MapAdminPersistenceToAdminEntity(adminPersistance));
        }
Esempio n. 2
0
        public void Map_admin_persistance_collection_to_admin_entity_collection_when_collection_is_null()
        {
            List <AdminPersistence> listOfAdminPersistences = null;

            Assert.Throws <ArgumentNullException>(()
                                                  => AdminMapper.MapAdminPersistenceCollectionToAdminEntityCollection(listOfAdminPersistences));
        }
Esempio n. 3
0
 public Admin GetAdminById(Guid id)
 {
     using (MQuinceDbContext _context = new MQuinceDbContext(_dbContext))
     {
         return(AdminMapper.MapAdminPersistenceToAdminEntity(_context.Admin.SingleOrDefault(c => c.Id.Equals(id))));
     }
 }
Esempio n. 4
0
        public IActionResult Invite()
        {
            var organizationUid = CurrentUser.OrganizationUid;
            var model           = AdminMapper.MapAdminInviteModel(organizationUid);

            return(View(model));
        }
Esempio n. 5
0
        public async Task UpdateAdmin(UpdateAdminDto adminDto)
        {
            var admin = await _adminRepository.GetByPesel(adminDto.Pesel);

            admin = AdminMapper.UpdateAdminMap(adminDto, admin);
            await _adminRepository.UpdateAdmin(admin);
        }
Esempio n. 6
0
 public IEnumerable <Admin> GetAllAdmins()
 {
     using (MQuinceDbContext _context = new MQuinceDbContext(_dbContext))
     {
         return(AdminMapper.MapAdminPersistenceCollectionToAdminEntityCollection(_context.Admin.ToList()));
     }
 }
Esempio n. 7
0
        public void Map_admin_entities_collection_to_identifier_adminDTO_collection_when_entities_collection_is_null()
        {
            List <Admin> listOfAdmins = null;

            Assert.Throws <ArgumentNullException>(()
                                                  => AdminMapper.MapAdminEntityCollectionToIdentifierAdminDTOCollection(listOfAdmins));
        }
Esempio n. 8
0
        public void Map_admin_entity_to_identifier_admin_dto_when_when_entity_is_null()
        {
            Admin admin = null;

            Assert.Throws <ArgumentNullException>(()
                                                  => AdminMapper.MapAdminEntityToIdentifierAdminDTO(admin));
        }
Esempio n. 9
0
        public void Map_admin_entity_to_identifier_admin_dto()
        {
            Admin admin = this.GetAdminFirts();

            IdentifiableDTO <AdminDTO> identifierAdminDTO = AdminMapper.MapAdminEntityToIdentifierAdminDTO(admin);

            Assert.True(IsEqualAdminEntitiesAndIdentifierAdminDTO(admin, identifierAdminDTO));
        }
Esempio n. 10
0
        public void Map_admin_persistence_to_admin_entity()
        {
            AdminPersistence adminPersistance = this.GetAdminPersistanceFirst();

            Admin adminEntity = AdminMapper.MapAdminPersistenceToAdminEntity(adminPersistance);

            Assert.True(this.IsEqualAdminPersistanceAndAdminEntity(adminPersistance, adminEntity));
        }
Esempio n. 11
0
        public void Map_admin_persistances_collection_to_admin_entities_collection()
        {
            List <AdminPersistence> listOfAdminPersistences = this.GetListOfAdminPersistance();

            List <Admin> listOfAdminEntities = AdminMapper.MapAdminPersistenceCollectionToAdminEntityCollection(listOfAdminPersistences).ToList();

            Assert.True(this.IsEqualAdminPersistanceAndAdminEntity(listOfAdminPersistences[0], listOfAdminEntities[0]));
            Assert.True(this.IsEqualAdminPersistanceAndAdminEntity(listOfAdminPersistences[1], listOfAdminEntities[1]));
        }
Esempio n. 12
0
        public void Map_admin_entites_collection_to_identifier_adminDTO_collection()
        {
            List <Admin> listOfAdmins = this.GetListOfAdmins();

            List <IdentifiableDTO <AdminDTO> > listOfIdentifierAdminDTO = AdminMapper.MapAdminEntityCollectionToIdentifierAdminDTOCollection(listOfAdmins).ToList();

            Assert.True(this.IsEqualAdminEntitiesAndIdentifierAdminDTO(listOfAdmins[0], listOfIdentifierAdminDTO[0]));
            Assert.True(this.IsEqualAdminEntitiesAndIdentifierAdminDTO(listOfAdmins[1], listOfIdentifierAdminDTO[1]));
        }
Esempio n. 13
0
        public async Task <Admin> AddAdmin(Admin admin)
        {
            var maxtrys    = _appConfig.MaxTrys;
            var timeTowait = TimeSpan.FromSeconds(_appConfig.Time);
            var retryPolly = Policy.Handle <Exception>().WaitAndRetryAsync(maxtrys, i => timeTowait);

            return(await retryPolly.ExecuteAsync(async() =>
            {
                var data = await _adminRepository.Add(AdminMapper.Map(admin));
                return AdminMapper.Map(data);
            }));
        }
Esempio n. 14
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();

            //初始化映射
            AdminMapper.Initialize();
        }
Esempio n. 15
0
        public async Task <Admin> AddAdmin(Admin admin)
        {
            var maxTrys    = _appConfig.MaxTrys;
            var timeToWait = TimeSpan.FromSeconds(_appConfig.SecondsToWait);

            var retryPolity = Policy.Handle <Exception>().WaitAndRetryAsync(maxTrys, i => timeToWait);

            // Politica para reintentar consultar llegado el caso exista un error en el servidor
            return(await retryPolity.ExecuteAsync(async() => {
                var addedEntity = await _AdminRepository.Add(AdminMapper.Map(admin));
                return AdminMapper.Map(addedEntity);
            }));
        }
Esempio n. 16
0
        public bool login()
        {
            AdminMapper adminmapper = new AdminMapper(MysqlDb.GetInstance());

            if (adminmapper.CheckLogin("admin", passwordBox1.Password))
            {
                return(true);
            }
            else
            {
                MessageBox.Show("Wachtwoord is onjuist.");
                return(false);
            }
        }
        /// <summary>
        ///     Abre una sesión de administrador.
        ///     Envia al repositorio las credenciales del administrador.
        ///     Si el repositorio reconoce las credenciales, instancia
        ///     un token para el role Admin.
        /// </summary>
        /// <param name="admin">
        ///     Objeto Admin con las credenciales
        /// </param>
        /// <exception cref="WrongCredentialsException">
        ///     Lanza WrongCredentialsException
        /// </exception>
        /// <returns>
        ///     retorna un objeto que contiene el token creado y
        ///     el id del administrador
        /// </returns>
        public async Task <AdminSignInResponse> SignIn(Admin admin)//Throw WrongCredentialsException
        {
            AdminEntity adminEntity = AdminMapper.Map(admin);

            var signedInAdmin = await _adminRepository.Exists(adminEntity);

            string token = _authService
                           .GenerateToken(signedInAdmin.AdminName + signedInAdmin.Password, Role.ADMIN);

            AdminSignInResponse response = new AdminSignInResponse
            {
                Id    = adminEntity.Id,
                Token = token
            };

            return(response);
        }
Esempio n. 18
0
        public async Task <IActionResult> AcceptInvite(Guid token, string email)
        {
            if (email.IsNotEmail() ||
                token.IsEmptyGuid())
            {
                return(RedirectToAccessDenied());
            }

            var request  = new AdminInviteValidateRequest(token, email);
            var response = await _adminService.ValidateSuperAdminUserInvitation(request);

            if (response.Status.IsNotSuccess)
            {
                return(RedirectToAccessDenied());
            }

            var model = AdminMapper.MapAdminAcceptInviteModel(response.Item, token, email);

            return(View(model));
        }
Esempio n. 19
0
        public async Task <User> GetUser()
        {
            string url = String.Concat(DataConstants.Endpoint, DataConstants.UserURL);

            var response = await MakeSessionHttpCall <BaseResponse <UserData>, string>(url, HttpVerbMethod.Get, null)
                           .ConfigureAwait(false);

            if (response.HasError)
            {
                if (response.info != null && response.info.Count() > 0)
                {
                    response.Message = String.Join("\n", response.info.Select(x => x.message));
                }
                throw new ApiException()
                      {
                          Code  = response.status,
                          Error = response.Message
                      };
            }

            return(AdminMapper.MapUser(response.data.ElementAt(0)));
        }
Esempio n. 20
0
        public async Task <IActionResult> Update(int id, [FromBody] AdminModel admin)
        {
            var data = await _adminService.UpdateAdmin(AdminMapper.Map(admin));

            return(Ok(data));
        }
Esempio n. 21
0
        public async Task <Admin> UpdateAdmin(Admin admin)
        {
            var data = await _adminRepository.Update(AdminMapper.Map(admin));

            return(admin);
        }
Esempio n. 22
0
        public async Task <Admin> GetAdmin(int id)
        {
            var data = await _adminRepository.Get(id);

            return(AdminMapper.Map(data));
        }
Esempio n. 23
0
        public async Task <IActionResult> AddAdmin([FromBody] AdminModel admin)
        {
            var newAdmin = await _adminService.AddAdmin(AdminMapper.Map(admin));

            return(Ok(newAdmin));
        }
Esempio n. 24
0
        public async Task <IActionResult> UpdateAdmin([FromBody] AdminModel admin)
        {
            var name = await _adminService.UpdateAdmin(AdminMapper.Map(admin));

            return(Ok(name));
        }
Esempio n. 25
0
        public async Task <IActionResult> Add([FromBody] AdminModel admin)
        {
            var data = await _adminService.AddAdmin((AdminMapper.Map(admin)));

            return(Ok(data));
        }
Esempio n. 26
0
        public async Task <Admin> UpdateAdmin(Admin admin)
        {
            var updated = await _AdminRepository.Update(AdminMapper.Map(admin));

            return(AdminMapper.Map(updated));
        }
Esempio n. 27
0
        public async Task <Admin> GetAdmin(int id)
        {
            var entidad = await _adminRepository.Get(id);

            return(AdminMapper.Map(entidad));
        }