예제 #1
0
        public async Task Create(MarvelousPropServiceModel model)
        {
            var exceptionMessage = "";

            try
            {
                var marvelousProp = Mapper.Map <MarvelousProp>(model);

                await this.context.MarvelousProps.AddAsync(marvelousProp);

                await this.context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                exceptionMessage = ex.Message;
                throw new CreatePropException();
            }
        }
예제 #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"));
        }