Beispiel #1
0
        public async Task <IActionResult> AddColumn(ColumnAddDto dto)
        {
            var columnToCreate = _mapper.Map <Column>(dto);

            _repo.Add <Column>(columnToCreate);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            throw new Exception("Creating the column failed on save");
        }
        public async Task <IActionResult> AddGrid(int userId)
        {
            var gridToCreate = new Grid(userId);

            // var gridToCreate = _mapper.Map<Grid>(dto);

            _repo.Add <Grid>(gridToCreate);

            if (await _repo.SaveAll())
            {
                return(Ok(gridToCreate.Id));
            }

            throw new Exception("Creating the grid failed on save");
        }
        public async Task <IActionResult> Add(FeedRssAddDto dto)
        {
            // if (await _repo.ca ..UserExists(userForRegisterDto.Username))
            //     return BadRequest("Username already exists");

            var rssToCreate = _mapper.Map <FeedRss>(dto);

            _repo.Add <FeedRss>(rssToCreate);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            throw new Exception("Creating the rss failed on save");
        }
Beispiel #4
0
        public async Task <IActionResult> UpdateUser(int id, UserEditDto userForUpdateDto)
        {
            if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var userFromRepo = await _repo.GetUser(id);

            _mapper.Map(userForUpdateDto, userFromRepo);

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception($"Updating user {id} failed to save");
        }