Example #1
0
        public async Task <IActionResult> CreatePost(CreateSquirrelViewModel viewModel)
        {
            var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var currentUser = await _userManager.FindByIdAsync(userId);

            Squirrel squirrel = new Squirrel()
            {
                Name          = viewModel.Name,
                Image         = viewModel.Image,
                PartyTrick    = viewModel.PartyTrick,
                PartyStory    = viewModel.PartyStory,
                PartyLocation = viewModel.PartyLocation,
                PartySince    = viewModel.PartySince,
                Creator       = userId
            };

            _db.Squirrels.Add(squirrel);

            _db.SquirrelUser.Add(new SquirrelUser()
            {
                SquirrelId = squirrel.SquirrelId, UserId = userId, Squirrel = squirrel, User = currentUser
            });
            _db.SaveChanges();
            return(RedirectToAction("Details", "Parties", new { id = userId }));
        }
Example #2
0
        public IActionResult Index() //gonutsnonuts page
        {
            CreateSquirrelViewModel viewModel = new CreateSquirrelViewModel()
            {
                Image = Src.GetPhoto()
            };

            viewModel.Name = RandomThing.RandomName();
            return(View(viewModel));
        }
Example #3
0
 public IActionResult Create(CreateSquirrelViewModel viewModel) // form to add details
 {
     return(View(viewModel));
 }