Exemplo n.º 1
0
        public async Task <IActionResult> EditUser(Guid id, AdminEditUserViewModel model)
        {
            ICreateEditEntityDto castedModel = (ICreateEditEntityDto)model;

            castedModel.Area       = "Admin";
            castedModel.Controller = this.GetType().Name.Replace("Controller", string.Empty);
            castedModel.Action     = "Edit";
            castedModel.EntityName = "User";
            this.ViewData[BreadcrumbEntityNamePluralPlaceholder] = "Users";
            this.ModelState.Remove("Area");
            this.ModelState.Remove("Controller");
            this.ModelState.Remove("Action");
            this.ModelState.Remove("EntityName");

            if (this.ModelState.IsValid)
            {
                if (await this.identityService.EditUserAsync(model.Id, model.Email, model.FirstName, model.LastName))
                {
                    this.TempData["SuccessStatusMessage"] = "User data has been successfully edited.";
                    return(this.RedirectToAction("GetAll", this.ControllerName));
                }
            }

            return(this.View("AbstractViews/Edit", castedModel));
        }
Exemplo n.º 2
0
        public virtual async Task <IActionResult> Edit(Guid id, TEntityDto model)
        {
            if (!HasGenericCreate)
            {
                return(NotFound());
            }

            ICreateEditEntityDto castedModel = (ICreateEditEntityDto)model;

            castedModel.Area       = "Admin";
            castedModel.Controller = this.GetType().Name.Replace("Controller", string.Empty);
            castedModel.Action     = "Edit";
            castedModel.EntityName = StringFunctions.SplitWordsByCapitalLetters(typeof(TEntity).Name);
            ViewData[BreadcrumbEntityNamePluralPlaceholder] = castedModel.EntityName.ToPluralString();
            ModelState.Remove("Area");
            ModelState.Remove("Controller");
            ModelState.Remove("Action");
            ModelState.Remove("EntityName");

            if (ModelState.IsValid)
            {
                var modifiedEntityId = await this.entityManager.ModifyEntityAsync <TEntity, TEntityDto>(id, model);

                if (modifiedEntityId.HasValue)
                {
                    return(RedirectToAction("Details", this.controllerName, new { id = modifiedEntityId }));
                }
            }

            return(View("AbstractViews/Edit", castedModel));
        }
Exemplo n.º 3
0
        public virtual async Task <IActionResult> EditUser(Guid id)
        {
            ICreateEditEntityDto model = (ICreateEditEntityDto)(await this.EntityManager.GetEntityAsync <User, AdminEditUserViewModel>(id));

            model.Area       = "Admin";
            model.Controller = this.GetType().Name.Replace("Controller", string.Empty);
            model.Action     = "EditUser";
            model.EntityName = "User";
            this.ViewData[BreadcrumbEntityNamePluralPlaceholder] = "Users";

            return(this.View("AbstractViews/Edit", model));
        }
Exemplo n.º 4
0
        public virtual async Task <IActionResult> Edit(Guid id)
        {
            if (!HasEdit)
            {
                return(NotFound());
            }

            ICreateEditEntityDto model = (ICreateEditEntityDto)(await this.entityManager.GetEntityAsync <TEntity, TEntityDto>(id));

            model.Area       = "Admin";
            model.Controller = this.GetType().Name.Replace("Controller", string.Empty);
            model.Action     = "Edit";
            model.EntityName = StringFunctions.SplitWordsByCapitalLetters(typeof(TEntity).Name);
            ViewData[BreadcrumbEntityNamePluralPlaceholder] = model.EntityName.ToPluralString();

            return(View("AbstractViews/Edit", model));
        }
Exemplo n.º 5
0
        public virtual async Task <IActionResult> Create()
        {
            if (!HasGenericCreate)
            {
                return(NotFound());
            }

            ICreateEditEntityDto model = (ICreateEditEntityDto) new TEntityDto();

            model.Area       = "Admin";
            model.Controller = this.GetType().Name.Replace("Controller", string.Empty);
            model.Action     = "Create";
            model.EntityName = StringFunctions.SplitWordsByCapitalLetters(typeof(TEntity).Name);
            ViewData[BreadcrumbEntityNamePluralPlaceholder] = model.EntityName.ToPluralString();

            return(View("AbstractViews/Create", model));
        }