예제 #1
0
        public async Task <IActionResult> Delete(MarvelousPropEditViewModel model, string id)
        {
            var userId = this.userManager.GetUserId(this.User);
            var user   = await this.userManager.FindByIdAsync(userId);

            await this.marvelousPropsService.Delete(id);

            if (await this.userManager.IsInRoleAsync(user, GlobalConstants.AdminRoleName))
            {
                return(this.RedirectToAction("Index", "Home"));
            }

            return(this.RedirectToAction("Index", "Home"));
        }
예제 #2
0
        public async Task <IActionResult> Create(MarvelousPropEditViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View());
            }

            MarvelousPropServiceModel marvelousProp = new MarvelousPropServiceModel()
            {
                Name               = model.Name,
                PropType           = Enum.Parse <MarvelousType>(model.PropType),
                Points             = model.Points,
                ImageUrl           = model.ImageUrl,
                Hashtags           = model.Hashtags,
                Description        = model.Description,
                MarvelousCreatorId = this.userManager.GetUserId(this.User),
                //MarvelousCreator = await this.usersService.GetUser(this.User.Identity.Name),
            };

            await this.marvelousPropsService.Create(marvelousProp);

            return(this.RedirectToAction("Index", "Home"));
        }