Esempio n. 1
0
        public IActionResult EditListName([FromBody] EditListNameDto editListNameDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var result = _listService.EditListName(editListNameDto);

            if (!result)
            {
                return(BadRequest());
            }
            return(NoContent());
        }
Esempio n. 2
0
        public bool EditListName(EditListNameDto editListNameDto)
        {
            if (!_context.Boards.Any(x => x.Id == editListNameDto.BoardId))
            {
                return(false);
            }
            var list = _context.Lists.SingleOrDefault(l => l.Id == editListNameDto.ListId);

            if (list == null || list.Name == editListNameDto.Name)
            {
                return(false);
            }
            list.Name = editListNameDto.Name;
            //edytowanie obiektow z bazy danych mozna updatowac w ten sposob, ze pobieramy obiekt z contextu
            //nastepnie zmieniamy tylko property ktore chcemy zmienic i robimy saveChanges na
            var result = _context.SaveChanges();

            return(result > 0);
        }
Esempio n. 3
0
        public bool EditListName(EditListNameDto editListNameDto)
        {
            if (!_context.Boards.Any(x => x.Id == editListNameDto.BoardId))
            {
                return(false);
            }

            var list = _context.Lists.SingleOrDefault(l => l.Id == editListNameDto.ListId);

            if (list == null || list.Name == editListNameDto.Name)
            {
                return(false);
            }

            list.Name = editListNameDto.Name;

            var result = _context.SaveChanges();

            return(result > 0);
        }