public async Task <RepositoryResponse <BETemplateViewModel> > Post(BETemplateViewModel model) { if (model != null) { var result = await model.SaveModelAsync(true).ConfigureAwait(false); return(result); } return(new RepositoryResponse <BETemplateViewModel>()); }
public async Task <IActionResult> Create(int templateId, BETemplateViewModel template) { if (ModelState.IsValid) { template.CreatedDateTime = DateTime.UtcNow; Domain.Core.ViewModels.RepositoryResponse <BETemplateViewModel> result = await template.SaveModelAsync(true).ConfigureAwait(false); if (result.IsSucceed) { return(RedirectToAction("Index", new { templateId = template.TemplateId, folder = template.FolderType })); } else { return(View(template)); } } return(View(template)); }
public async Task <IActionResult> Edit(int id, BETemplateViewModel template) { if (id != template.Id) { return(NotFound()); } if (ModelState.IsValid) { try { template.ModifiedBy = User.Identity.Name; template.LastModified = DateTime.UtcNow; var result = await template.SaveModelAsync(true).ConfigureAwait(false); if (result.IsSucceed) { return(RedirectToAction("Index", new { templateId = template.TemplateId, folder = template.FolderType })); } else { ModelState.AddModelError(string.Empty, result.Exception.Message); return(View(template)); } } catch (DbUpdateConcurrencyException) { if (!BETemplateViewModel.Repository.CheckIsExists(m => m.Id == template.Id)) { return(NotFound()); } else { throw; } } //return RedirectToAction("Index"); } ViewData["Action"] = "Edit"; ViewData["Controller"] = "TemplateFile"; return(View(template)); }
public IActionResult Create(int templateId) { var getTemplate = BEThemeViewModel.Repository.GetSingleModel(t => t.Id == templateId); if (getTemplate.IsSucceed) { var TemplateFile = new BETemplateViewModel() { ModifiedBy = User.Identity.Name, Extension = SWCmsConstants.Parameters.TemplateExtension, TemplateId = templateId, TemplateName = getTemplate.Data.Name }; return(View(TemplateFile)); } else { return(NotFound()); } }