Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("FName,LName,Email,Gender")] Users users)
        {
            if (HttpContext.Session.GetInt32("AId") < 0)
            {
                return(RedirectToAction("Login", "Admins"));
            }
            if (ModelState.IsValid)
            {
                _context.Add(users);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));//asdf
                return(RedirectToAction("Details", "Users", new { id = users.UId }));
            }
            return(View(users));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("AId,Username,Password,Email")] Admin admin)
        {
            if (HttpContext.Session.GetInt32("AId") < 0)
            {
                return(RedirectToAction("Login", "Admins"));
            }

            if (ModelState.IsValid)
            {
                admin.Password = GetMd5Hash(MD5.Create(), "xfo3ip2a51s23d15g5j" + admin.Password + "$4Lt");
                _context.Add(admin);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(admin));
        }
        public async Task <IActionResult> Create([Bind("RelId,FName,LName,Relation,UId")] Relative relative)
        {
            if (HttpContext.Session.GetInt32("AId") < 0)
            {
                return(RedirectToAction("Login", "Admins"));
            }

            if (ModelState.IsValid)
            {
                _context.Add(relative);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "Users", new { id = relative.UId }));
            }
            ViewData["UId"] = new SelectList(_context.Users, "UId", "UId", relative.UId);
            Console.WriteLine(ViewData["UId"]);
            return(View(relative));
        }