Example #1
0
        public ActionResult Read()
        {
            IEnumerable <Contact> contacts;

            if (User.IsInRole("Admin") || User.IsInRole("ContactListAdmin"))
            {
                contacts = _contactService.GetAll();
            }
            else
            {
                string            userId           = _identityUserService.FindUserIdByName(User.Identity.Name);
                IEnumerable <int> userContactLists = _userContactListService.GetAll(r => r.UserId == userId).Select(r => r.ContactListId);
                contacts = (IEnumerable <Contact>)_contactService.GetAll(r => userContactLists.Contains(r.ContactListId));
            }
            var a = contacts.MapModelToViewModel();

            return(Json(a, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Read()
        {
            IEnumerable <UserContactListViewModel> a = from r in _userContactListService.GetAll()
                                                       select new UserContactListViewModel
            {
                Id              = r.Id,
                UserName        = _identityUserService.FindUserNameById(r.UserId),
                ContactListName = r.ContactList.Name
            };

            return(Json(a, JsonRequestBehavior.AllowGet));
        }
Example #3
0
 public ActionResult DeleteConfirmed(int id)
 {
     foreach (var a in _contactGroupService.GetAll(r => r.ContactListId == id))
     {
         _contactGroupService.DeleteById(a.Id);
     }
     foreach (var a in _contactService.GetAll(r => r.ContactListId == id))
     {
         _contactService.DeleteById(a.Id);
     }
     foreach (var a in _userContactListService.GetAll(r => r.ContactListId == id))
     {
         _userContactListService.DeleteById(a.Id);
     }
     _contactListService.DeleteById(id);
     _uow.SaveChanges();
     return(Json(new { success = true }));
 }