Example #1
0
        public async Task <IActionResult> Create([Bind("PropName,Id")] ThematicProp thematicProp)
        {
            if (ModelState.IsValid)
            {
                _context.Add(thematicProp);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(thematicProp));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("UserId,ThematicPropId,PropPrice,PropDescription,EndBidDate,Id")] PropAd propAd)
        {
            if (ModelState.IsValid)
            {
                propAd.UserId = Convert.ToInt32(HttpContext.Session.GetString("Id"));
                _context.Add(propAd);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ThematicPropId"] = new SelectList(_context.ThematicProps, "Id", "PropName", propAd.ThematicPropId);
            ViewData["UserId"]         = new SelectList(_context.Users, "Id", "EmailAddress", propAd.UserId);
            return(View(propAd));
        }