Esempio n. 1
0
        public async Task <ActionResult> Edit(Guid id)
        {
            var theme = await _themeAdminService.GetThemeByIdAsync(id);

            EditThemeRequest editThemeRequest = theme.ToEditThemeRequest();

            ViewBag.Title = $"Edit theme \"{theme.Title}\"";
            return(View(editThemeRequest));
        }
Esempio n. 2
0
        public async Task <ActionResult> Edit(EditThemeRequest model)
        {
            if (ModelState.IsValid)
            {
                await _themeAdminService.EditThemeAsync(model);

                return(RedirectToAction("Index", new { subjectId = model.SubjectId }));
            }
            ViewBag.Title = "Edit theme";
            return(View(model));
        }
Esempio n. 3
0
        /// <summary>
        /// Edit unpublished theme.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public virtual ActionResult Edit(string id)
        {
            var theme     = _ThemeService.GetTheme(id);
            var viewModel = new EditThemeRequest(id)
            {
                Items = theme.UnpublishedItems.ToDictionary(
                    k => k.Key,
                    v => v.Value.Values.ToArray())
            };

            return(View(viewModel));
        }
Esempio n. 4
0
        public static EditThemeRequest ToEditThemeRequest(this ThemeResponse themeResponse)
        {
            EditThemeRequest editThemeRequest = new EditThemeRequest()
            {
                Id        = themeResponse.Id,
                SubjectId = themeResponse.SubjectId,
                Title     = themeResponse.Title,
                TimeLine  = themeResponse.TimeLine
            };

            return(editThemeRequest);
        }
Esempio n. 5
0
        public async Task EditThemeAsync(EditThemeRequest model)
        {
            var theme = await UnitOfWork.ThemeRepository.Query(x => x.Id == model.Id)
                        .FirstOrDefaultAsync();

            if (theme == null)
            {
                throw new ArgumentNullException();
            }

            if (theme.Title != model.Title || theme.TimeLine != model.TimeLine)
            {
                theme.Title    = model.Title;
                theme.TimeLine = model.TimeLine;

                UnitOfWork.ThemeRepository.Update(theme);
                await UnitOfWork.SaveChangesAsync();
            }
        }