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)); }
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)); }
/// <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)); }
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); }
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(); } }