Esempio n. 1
0
        public ActionResult Edit(int id)
        {
            var result = _repository.FindById(id);

            if (result == null)
            {
                return(HttpNotFound());
            }

            var newResult = Mapper.Map <News, NewsDtoForUpdate>(result);

            var categoriesRepository = new GlobalRepository <NewsCategory>();
            var categories           = categoriesRepository.FindAll();

            var newsForm = new NewsForm
            {
                Title          = newResult.Title,
                Content        = newResult.Content,
                Image          = newResult.Image,
                NewsCategoryId = newResult.NewsCategoryId,
                NewsCategory   = newResult.NewsCategory,
                ModifiedBy     = newResult.ModifiedBy,
                ModifiedOn     = newResult.ModifiedOn,
                Categories     = GetAllCategories(categories),
                ViewMode       = Enums.ViewMode.Edit
            };

            return(View(newsForm));
        }
        public ActionResult Edit(int id)
        {
            var result = _repository.FindById(id);

            if (result == null)
            {
                return(HttpNotFound());
            }

            var category = Mapper.Map <NewsCategory, NewsCategoryDtoForUpdate>(result);

            var newsCategoryForm = new NewsCategoryForm
            {
                Name     = category.Name,
                ViewMode = Enums.ViewMode.Edit
            };

            ViewBag.CategoryId = result.Id;

            return(View(newsCategoryForm));
        }