示例#1
0
        private async Task <IRoleObjectViewModel> PopulateInitialValuesAsync(IRoleObjectViewModel model, CancellationToken cancellationToken)
        {
            if (model == null)
            {
                model = new RoleObjectViewModel();
            }
            model.DDLRoleList = await _ddlDAL.GetRoleListAsync(userId, cancellationToken, true);

            return(model);
        }
示例#2
0
        public async Task <ActionResult> Index(RoleObjectViewModel smodel, CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                ViewData[Constant.CustomSuccessMessage] = Constant.CustomValidationErrorMessage;
                ViewData[Constant.QuerySuccess]         = false;
                smodel = (RoleObjectViewModel)await _service.IndexAsync(this.HttpContext.ApplicationInstance.Context, GetCanellationToken(cancellationToken));

                return(View(smodel));
            }
            ModelState.Clear();
            IRoleObjectViewModel model = await _service.SaveAsync(this.HttpContext.ApplicationInstance.Context, smodel, GetCanellationToken(cancellationToken));

            ViewData[Constant.QuerySuccess] = HttpContext.Items[Constant.QuerySuccess];
            ViewData[Constant.FormTitle]    = HttpContext.Items[Constant.FormTitle];
            if (!Convert.ToBoolean(ViewData[Constant.QuerySuccess]))
            {
                ViewData[Constant.CustomSuccessMessage] = "Error : Record cannot  be Saved. Make sure the 'Role Name' isn't being duplicated.";
            }
            return(View(model));
        }