public ActionResult Update(UpdateSectionViewModel updateSectionView)
        {
            var updateSectionDto = Mapper.Map <UpdateSectionDto>(updateSectionView);

            _sectionService.UpdateSection(updateSectionDto);

            return(RedirectToAction("Item", "Section", new { Id = updateSectionView.SectionId }));
        }
        public async Task <ActionResult> UpdateSection(int id, UpdateSectionViewModel updateSectionViewModel)
        {
            var section = await sectionRepository.GetByIdAsync(id);

            if (section == null)
            {
                return(NotFound());
            }

            var products = await productRepository.GetByIdsAsync(updateSectionViewModel.ProductIds);

            if (products == null || products.Count != updateSectionViewModel.ProductIds.Count)
            {
                return(BadRequest(new ValidationErrors("Not all products were found.")));
            }

            await sectionRepository.UpdateAsync(updateSectionViewModel.Title, section, products);

            return(NoContent());
        }
Beispiel #3
0
        // PUT api/<controller>/5
        public void Put(UpdateSectionViewModel updateSectionView)
        {
            var updateSectionDto = Mapper.Map <UpdateSectionDto>(updateSectionView);

            _sectionService.UpdateSection(updateSectionDto);
        }