Beispiel #1
0
        private OperationResult <PageLocalizationDto> UpdatePageLocalization(PageLocalizationDto localization, PageLocalization domainLocalization)
        {
            domainLocalization = Mapper.Map(localization, domainLocalization);
            var result = _repository.Update(domainLocalization);

            _repository.Save();

            return(OperationResult.Success(Mapper.Map <PageLocalizationDto>(result)));
        }
Beispiel #2
0
        private OperationResult <PageLocalizationDto> CreatePageLocalization(PageLocalizationDto localization)
        {
            var domainLocalization = Mapper.Map <PageLocalization>(localization);
            var result             = _repository.Create(domainLocalization);

            _repository.Save();

            return(OperationResult.Success(Mapper.Map <PageLocalizationDto>(result)));
        }
Beispiel #3
0
        public ActionResult Edit(int id, PageMvcViewModel model)
        {
            if (ModelState.IsValid == false)
            {
                return(View(model));
            }

            if (model.Id == 0)
            {
                throw new HttpException((int)HttpStatusCode.InternalServerError, "Не указан идентификатор категории");
            }

            var enLocalization = new PageLocalizationDto
            {
                Html       = model.ContentEn,
                LanguageId = (int)CultureLanguage.EN,
                PageId     = model.Id,
                Title      = model.TitleEn
            };

            var ruLocalization = new PageLocalizationDto
            {
                Html       = model.ContentRu,
                LanguageId = (int)CultureLanguage.RU,
                PageId     = model.Id,
                Title      = model.TitleRu
            };

            var result = _pageService.SaveLocalizations(model.Name, ruLocalization, enLocalization);

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", $"Ошибки при обновлении новости:</br>" + $"{string.Join("</br>", result.Errors)}");
                return(View(model));
            }

            return(RedirectToAction("Index"));
        }