Exemple #1
0
        private async Task <IWebAPIRoleObjectViewModel> PopulateInitialValuesAsync(IWebAPIRoleObjectViewModel model, CancellationToken cancellationToken)
        {
            if (model == null)
            {
                model = new WebAPIRoleObjectViewModel();
            }
            model.DDLRoleList = await _ddlDAL.GetWebAPIRoleListAsync(userId, cancellationToken, true);

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

                return(View(smodel));
            }
            ModelState.Clear();
            IWebAPIRoleObjectViewModel 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));
        }