Exemplo n.º 1
0
        public async Task <IActionResult> Create(
            [Bind("EnrollmentDate,FirstMidName,LastName")] QueueModel queue)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _dogsDB.Add(queue);
                    await _dogsDB.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }
            return(View(queue));
        }
Exemplo n.º 2
0
        public ActionResult Registar(RegistrationViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var emailParam = new SqlParameter("email", model.Email);
                    var email      = _dogsDB.Userdetails.FromSqlRaw("EXECUTE SP_UserValidation @email", emailParam).ToList();
                    if (email.Count > 0)
                    {
                        ViewBag.EmailErrorMsg = "User with the same Email Already Exist";
                        return(View("Register"));
                    }
                    else
                    {
                        UsersModel user = new UsersModel
                        {
                            userName    = model.Email,
                            displayName = model.Name,
                            email       = model.Email,
                            password    = model.Password,
                            phone       = model.Mobile
                        };

                        _dogsDB.Add(user);
                        _dogsDB.SaveChangesAsync();
                    }
                }
                catch (Exception ex)
                {
                    return(RedirectToAction(nameof(Login)));
                }
            }
            else
            {
                return(View("Register"));
            }
            return(RedirectToAction("Index", "Account"));
        }