Ejemplo n.º 1
0
        public async Task <IActionResult> Delete(PropEditViewModel model, string id)
        {
            var userId = this.userManager.GetUserId(this.User);
            var user   = await this.userManager.FindByIdAsync(userId);

            await this.propsService.Delete(id);

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

            return(this.RedirectToAction("My", "Props"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(PropEditViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View());
            }

            PropServiceModel prop = new PropServiceModel()
            {
                Name          = model.Name,
                PropType      = Enum.Parse <PropType>(model.PropType),
                Price         = model.Price,
                ImageUrl      = model.ImageUrl,
                Hashtags      = model.Hashtags,
                Description   = model.Description,
                PropCreatorId = this.userManager.GetUserId(this.User),
                //PropCreator = await this.usersService.GetUser(this.User.Identity.Name),
            };

            await this.propsService.Create(prop);

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