Esempio n. 1
0
        public void Remove(Guid id)
        {
            var entity = _context.Admin.Find(AdminQueries.GetAdminById(id));

            _context.Admin.Remove(entity);
            _context.SaveChanges();
        }
Esempio n. 2
0
        public void Can_update_admin()
        {
            var admin = SecurityTestHelper.CreateAdmin();

            var firstName   = TestDataGenerator.GetRandomString();
            var lastName    = TestDataGenerator.GetRandomString();
            var status      = true;
            var language    = TestDataGenerator.GetRandomString();
            var description = TestDataGenerator.GetRandomString();

            admin.FirstName   = firstName;
            admin.LastName    = lastName;
            admin.IsActive    = status;
            admin.Language    = language;
            admin.Description = description;

            var adminData = Mapper.DynamicMap <EditAdminData>(admin);

            adminData.AllowedBrands     = admin.AllowedBrands.Select(b => b.Id).ToList();
            adminData.AssignedLicensees = admin.Licensees.Select(l => l.Id).ToList();
            adminData.Password          = TestDataGenerator.GetRandomString();

            AdminCommands.UpdateAdmin(adminData);

            admin = AdminQueries.GetAdminById(admin.Id);

            Assert.True(admin.FirstName == firstName);
            Assert.True(admin.LastName == lastName);
            Assert.True(admin.IsActive == status);
            Assert.True(admin.Language == language);
            Assert.True(admin.Description == description);
        }
Esempio n. 3
0
        public bool VerifyAdmin(int admin_id, string token)  //use to login admin
        {
            Admin QueryAdmin;

            try{
                QueryAdmin = dbQueryA.GetAdminById(admin_id);
            }catch {
                return(false);
            }
            if (QueryAdmin.token == token && QueryAdmin.email_verified)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public JsonResponse DeleteMethod(AdminRequestDto request)
 {
     if (authenticator.VerifyAdmin(request.admin_id, request.token))
     {
         Admin FoundAdmin = dbQuery.GetAdminById(request.admin_id);
         if (FoundAdmin.admin_id == request.admin_id)
         {
             dbQuery.DeleteAdminById(request.admin_id);
             return(new JsonSuccess("Admin sucessfully deleted. I hope that's what you wanted."));
         }
         else
         {
             return(new JsonFailure("Admin not found."));
         }
     }
     else
     {
         return(new JsonFailure("Invalid token. Stranger danger."));
     }
 }
Esempio n. 5
0
        public void Can_activate()
        {
            // *** Arrange ***
            var admin = SecurityTestHelper.CreateAdmin();

            // *** Act ***
            AdminCommands.Activate(new ActivateUserData(admin.Id, string.Empty));

            // *** Assert ***
            var activatedAdmin = AdminQueries.GetAdminById(admin.Id);

            Assert.IsNotNull(activatedAdmin);
            Assert.True(activatedAdmin.IsActive == true);
        }
Esempio n. 6
0
 public UserAdmin GetAdmin(Guid id)
 {
     return(_context.Admin.AsNoTracking().FirstOrDefault(AdminQueries.GetAdminById(id)));
 }