Beispiel #1
0
        /// <exception cref="ArgumentException">thrown if no author found</exception>
        public int Add(Domain.Link link)
        {
            var model = new LinkModel(link);

            var author = _context.Users.FirstOrDefault(x => x.Id == link.User.Id);

            if (author == null)
            {
                throw new NoUserFoundException();
            }

            // save link
            _context.Links.Add(model);

            // save because we need to generate id
            _context.SaveChanges();

            // save link to link (xd)
            author.LinkIds.Add(model.Id);

            _context.SaveChanges();
            _renderService.BuildUserPage(model.UserId);

            return(model.Id);
        }
Beispiel #2
0
 public void ChangeUserAvatarPath(int id, string path)
 {
     _userRepository.ChangeUserAvatarPath(id, path);
     _renderService.BuildUserPage(id);
 }