public ActionResult Registration(string username, string password, string confirmPassword, User user) { sexList = SQLProcedures.GetSexes(); activityLevelList = SQLProcedures.GetActivityLevels(); diabetesTypesList = new List <int> { 1, 2 }; if (!(username.Trim() == string.Empty) && username.Length < 50) { if (!SQLProcedures.CheckExistingUsername(username)) { if (password != string.Empty && password == confirmPassword && password.Length < 50) { if (ModelState.IsValid) { int activityLevelID = SQLProcedures.GetActivityLevelID(Request.Form["ddlActivityLevel"].ToString()); SQLProcedures.InsertUser(user, activityLevelID, username, password); return(RedirectToAction("UserLogin", "UserLogin")); } else { ViewBag.ErrorMessage = "Osobni podaci nisu popunjeni!"; ViewBag.ShowError = true; ViewBag.InsertedUsername = username; FillViewBags(); return(View("Registration", user)); } } else { if (password != confirmPassword) { ViewBag.ErrorMessage = "Lozinke se ne podudaraju!"; } if (password.Length > 64) { ViewBag.ErrorMessage = "Maksimalna duljina lozinke je 50!"; } if (password == string.Empty) { ViewBag.ErrorMessage = "Lozinka nije unesena!"; } ViewBag.ShowError = true; ViewBag.InsertedUsername = username; FillViewBags(); return(View("Registration")); } } else { ViewBag.ErrorMessage = "Username već postoji!"; ViewBag.ShowError = true; ViewBag.InsertedUsername = username; FillViewBags(); return(View("Registration")); } } else { if (username.Trim() == string.Empty) { ViewBag.ErrorMessage = "Username nije unesen!"; } if (username.Length > 50) { ViewBag.ErrorMessage = "Maksimalna duljina usernamea je 50!"; } FillViewBags(); ViewBag.ShowError = true; return(View("Registration")); } }