Пример #1
0
        private void lnkDelete_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var confirmation = MessageBox.Show(this, String.Format("Are you sure you would like to delete the profile '{0}'", cboProfile.Text), "Are you sure you want to delete?",
                                               MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);

            if (confirmation == DialogResult.No)
            {
                return;
            }
            var    profile     = (Profile)cboProfile.SelectedItem;
            string profileName = profile.Name;

            _profileService.Delete(profile);
            loadProfiles();
            toggleConfigurationGroup(false);

            if (cboProfile.Items.Count < 1)
            {
                toggleProfileButtons(false);
            }
            tstat.Text      = String.Format("Deleted profile '{0}'", profileName);
            _currentProfile = null;
            reset();
            toggleProfileButtons(false);
        }
Пример #2
0
 public async Task DeleteTest()
 {
     var fakeRepository = Mock.Of <IProfileRepository>();
     var ProfileService = new ProfileService(fakeRepository);
     int ProfileId      = 1;
     await ProfileService.Delete(ProfileId);
 }
 public async Task <ActionResult <Profile> > DeleteProfile(Guid id)
 {
     try
     {
         return(await _profileService.Delete(id));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Пример #4
0
        public async Task <IActionResult> Delete(String id)
        {
            var user = _dbContext.ExtUsers.Find(id);

            _dbContext.ExtUsers.Remove(user);
            await _dbContext.SaveChangesAsync();

            _profiles.Delete(id);

            return(RedirectToAction(nameof(Index)));
        }
Пример #5
0
 public ActionResult <Boolean> Delete(int id)
 {
     try
     {
         string nameIdentifier = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         if (nameIdentifier != null)
         {
             return(Ok(_profileService.Delete(id, nameIdentifier)));
         }
         else
         {
             throw new UnauthorizedAccessException("Unauthorized");
         }
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Пример #6
0
        public void TestDeleteProfile()
        {
            ProfileService service = new ProfileService();
            CompanyProfile profile = new CompanyProfile()
            {
                CompanyCvr  = 12345678,
                ProfileText = "This is the profile"
            };

            service.Create(profile);
            CompanyProfile profile2 = new CompanyProfile()
            {
                CompanyCvr  = 23456789,
                ProfileText = "This is the second profile"
            };

            service.Create(profile2);
            service.Delete(profile2.CompanyCvr);

            Assert.IsFalse(service.GetAll().Exists(x => x.CompanyCvr == profile2.CompanyCvr));
            Assert.AreEqual(service.GetAll().Count, 1);
        }