public async Task <IActionResult> OnPostDeleteAsync(int id) { if (id == 0) { TempData.Danger("Resource ID can't be empty"); return(RedirectToPage("Index")); } var entity = await _resManager.GetResourceAsync <XDbResource>(x => x.ID == id); if (entity == null) { TempData.Danger("Resource not found!"); return(RedirectToPage("Index")); } if (await _resManager.DeleteResourceAsync <XDbResource>(x => x.Key == entity.Key)) { TempData.Success("Deleted!"); } else { TempData.Danger("Unknown error occord!"); } return(RedirectToPage("Index")); }
public async Task <IActionResult> OnGetAsync() { if (ResourceID == 0) { TempData.Warning("Resource ID can't be zero!"); return(RedirectToPage("Resources")); } var res = await _resManager.GetResourceAsync <XDbResource>(x => x.ID == ResourceID); var exp = new List <Expression <Func <XDbResource, bool> > > { x => x.Key == res.Key }; int _; (Resources, _) = await _resManager.ResourcesSetListAsync(1, 848, exp); if (Resources == null) { TempData.Danger("Resource not found!"); return(RedirectToPage("Index")); } var culturesExp = new List <Expression <Func <XDbCulture, bool> > > { }; if (!string.IsNullOrWhiteSpace(TargetCulture)) { culturesExp.Add(x => x.ID == TargetCulture); } _ = 0; (Cultures, _) = await _culManager.CulturesListAsync(1, 848, null); DefaultCulture = Cultures?.SingleOrDefault(c => c.IsDefault == true)?.ID; return(Page()); }
public async Task <IActionResult> OnGetAsync() { var entity = await _resManager.GetResourceAsync <XDbResource>(x => x.ID == ID); if (entity == null) { TempData.Warning("Resource not found!"); return(RedirectToPage("Index")); } InputModel = new ResourceEditModel { Key = entity.Key }; return(Page()); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { await GetCulturesListAsync(); return(Page()); } var entity = await _resManager.GetResourceAsync <XDbResource>(x => x.Key == InputModel.Key && x.CultureID == InputModel.CultureID); if (entity != null) { TempData.Warning("Resource already exists!"); await GetCulturesListAsync(); return(Page()); } entity = new XDbResource { Key = InputModel.Key, Value = InputModel.Value, CultureID = InputModel.CultureID, Comment = InputModel.Comment, IsActive = InputModel.IsActive }; if (await _resManager.AddResourceAsync <XDbResource>(entity)) { TempData.Success("Resource added."); } else { TempData.Danger("Resource not added"); } return(RedirectToPage("Index")); }