public IActionResult UpdateMany([FromBody] IEnumerable <ArgumentDto> argumentsDto)
        {
            try
            {
                List <ArgumentDto> updatedlist = new List <ArgumentDto>();
                foreach (ArgumentDto argumentDto in argumentsDto)
                {
                    // map dto to entity and set id
                    var c = _mapper.Map <Argument>(argumentDto);

                    try
                    {
                        // save
                        c = _argumentService.Update(c);

                        updatedlist.Add(_mapper.Map <ArgumentDto>(c));
                    }
                    catch (AppException ex)
                    {
                        // return error message if there was an exception
                        return(BadRequest(ex.Message));
                    }
                }
                return(Ok(updatedlist));
            }
            catch (AppException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
示例#2
0
        public void Update(int id, IFormCollection data)
        {
            var model = new ArgumentModel();

            var categoryId = _argumentService.GetById(id).categoryId;

            model.id           = id;
            model.name         = data["name"];
            model.categoryId   = Convert.ToInt32(data["idCategory"]);
            model.description  = data["description"];
            model.coverImageId = Convert.ToInt32(data["coverImage"]);
            model.slugId       = _argumentService.GetById(id).slugId;

            UpdateSlug(model);

            _argumentService.Update(id, model);
        }