public JsonResult Save(GamificationLevelViewModel vm) { bool isNew = vm.Id == Guid.Empty; try { vm.UserId = CurrentUserId; OperationResultVo <Guid> saveResult = gamificationLevelAppService.Save(CurrentUserId, vm); if (saveResult.Success) { string url = Url.Action("index", "gamificationlevel", new { area = "staff" }); if (isNew && EnvName.Equals(ConstantHelper.ProductionEnvironmentName)) { NotificationSender.SendTeamNotificationAsync("New Gamification Level created!"); } return(Json(new OperationResultRedirectVo <Guid>(saveResult, url))); } else { return(Json(new OperationResultVo(false))); } } catch (Exception ex) { return(Json(new OperationResultVo(ex.Message))); } }
private async Task SetPermissions(GamificationLevelViewModel model) { ApplicationUser user = await UserManager.FindByIdAsync(CurrentUserId.ToString()); bool userIsAdmin = await UserManager.IsInRoleAsync(user, Roles.Administrator.ToString()); model.Permissions.IsAdmin = userIsAdmin; model.Permissions.CanDelete = model.Permissions.IsAdmin; }
public async Task <IActionResult> Add() { OperationResultVo serviceResult = await gamificationLevelAppService.GenerateNew(CurrentUserId); if (serviceResult.Success) { OperationResultVo <GamificationLevelViewModel> castResult = serviceResult as OperationResultVo <GamificationLevelViewModel>; GamificationLevelViewModel model = castResult.Value; return(View("CreateEditWrapper", model)); } else { return(View("CreateEditWrapper", new GamificationLevelViewModel())); } }