Example #1
0
 private void addFirstAdmin(Admin admin)
 {
     if (adminRepository.GetByUsername(admin.username) == null)
     {
         adminRepository.Add(admin);
     }
 }
        public void GetAdmin_ExistentAdmin_ShouldReturnSpecificAdminFromDB()
        {
            adminRepositoryInMemory.Add(sebaAdmin);
            adminRepositoryInMemory.Add(marcosAdmin);
            adminRepositoryInMemory.SaveChanges();

            Assert.AreEqual(adminRepositoryInMemory.Get(sebaAdmin.Id), sebaAdmin);
        }
        public async Task TestAddAdmin()
        {
            var admin = new TblAdmin();

            admin.AdminId = Guid.NewGuid();
            admin.UserId  = Guid.NewGuid();
            Assert.True(await repo.Add(admin));
        }
 public IHttpActionResult AddAdmin([FromBody] Admin admin)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         _adminRepository.Add(admin);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(Ok(admin));
 }
Example #5
0
        public async Task <IActionResult> Create(NewAccountViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var user = new IdentityUser {
                    UserName = vm.Usuario, Email = vm.Correo
                };
                var resul = await _userManager.CreateAsync(user, vm.ContraseƱa);

                var usuarioentity = _mapper.Map <Users>(vm);
                usuarioentity.Tipo   = vm.RoleSelect;
                usuarioentity.Estado = "Activo";
                usuarioentity.Id     = user.Id;



                if (resul.Succeeded)
                {
                    var resulrol = await _userManager.AddToRoleAsync(user, vm.RoleSelect);

                    if (resulrol.Succeeded)
                    {
                        await _adminrepository.Add(usuarioentity);

                        if (vm.RoleSelect.Equals("cliente"))
                        {
                            var productentity = new ProductosUsers();
                            productentity.Id        = DateTime.Now.ToString("HHyfffmm");
                            productentity.Idusuario = user.Id;
                            productentity.Idtipo    = 1;
                            productentity.Tipo      = "Principal";
                            productentity.Balance   = vm.MontoInicial;

                            await _productsrepository.Add(productentity);
                        }
                        return(RedirectToAction("Management"));
                    }
                }
            }
            return(View());
        }
Example #6
0
        public bool Add(AdminLogIn adminLogin)
        {
            bool isSave = _adminRepository.Add(adminLogin);

            return(isSave);
        }