Esempio n. 1
0
        public LinkForAdmin GetAdminLinkById(int id)
        {
            Link         link     = _repo.Query <Link>().Where(l => l.Id == id).Include(l => l.User).FirstOrDefault();
            LinkForAdmin listable = new LinkForAdmin
            {
                Id       = link.Id,
                Name     = link.Name,
                Url      = link.Url,
                LinkType = link.LinkType,
                UserName = link.User.UserName
            };

            return(listable);
        }
Esempio n. 2
0
        public void AdminUpdate(LinkForAdmin link)
        {
            // Convert this back to a normal Link object for saving ...
            Link linkToSave = new Link
            {
                Id       = link.Id,
                Name     = link.Name,
                Url      = link.Url,
                LinkType = link.LinkType
            };
            // pull the user info to keep that relationship
            ApplicationUser user = _repo.Query <ApplicationUser>().Where(u => u.UserName == link.UserName).FirstOrDefault();

            linkToSave.User = user;
            _repo.Update(linkToSave);
        }
Esempio n. 3
0
        public IList <LinkForAdmin> GetAllLinks()
        {
            IList <Link>         allLinks      = _repo.Query <Link>().Include(l => l.User).ToList();
            IList <LinkForAdmin> listableLinks = new List <LinkForAdmin>();

            foreach (Link link in allLinks)
            {
                LinkForAdmin listable = new LinkForAdmin
                {
                    Id       = link.Id,
                    Name     = link.Name,
                    Url      = link.Url,
                    LinkType = link.LinkType,
                    UserName = link.User.UserName
                };
                listableLinks.Add(listable);
            }
            return(listableLinks);
        }
 public IActionResult AdminUpdate([FromBody] LinkForAdmin link)
 {
     _service.AdminUpdate(link);
     return(Ok(link));
 }