Example #1
0
        public async Task <IActionResult> Create([Bind("DinnerID,Title,EventDate,Description,HostedBy,ContactPhone,Address,Country,Latitude,Longitude")] Dinner dinner)
        {
            ViewData["session"] = HttpContext.Session.GetString("userId");
            var uid = int.Parse(HttpContext.Session.GetString("Uid"));

            if (ModelState.IsValid)
            {
                dinner.LoginID = uid;
                _context.Add(dinner);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Logged)));
            }
            return(View(dinner));
        }
Example #2
0
 public async Task <ActionResult> Register(Register model)
 {
     if (ModelState.IsValid)
     {
         User user = new User
         {
             Name     = model.Name,
             Email    = model.Email,
             Password = model.Password,
         };
         _context.Add(user);
         await _context.SaveChangesAsync();
     }
     else
     {
         return(View("Register"));
     }
     return(RedirectToAction("Index", "Account"));
 }