public ActionResult Registration(RegistrationExt model)
        {
            //Redirect the User to Error/RestrictedEmailDomain if user enter any Restricted Email Domain while Registration
            string _Msg    = "";
            bool   _status = true;

            if (ModelState.IsValid)
            {
                if (SecurityUtils.IsRestrictedEmailDomainDetected(model.EmailAddress))
                {
                    SecurityUtils.AddAuditLog("Restricted Email Address Detected", "Restricted Email Address: " + model.EmailAddress);

                    return(Json(new { status = false, Msg = "Restricted Email Address: " + model.EmailAddress }, JsonRequestBehavior.AllowGet));
                }

                PlayersExt        player     = MAP_Registration(model);
                PlayersRepository playerRepo = new PlayersRepository();
                playerRepo.CreateOrUpdate(ref player, ref _Msg, ref _status, this);


                return(Json(new { status = _status, Msg = _Msg }, JsonRequestBehavior.AllowGet));
            }

            foreach (ModelState modelState in ViewData.ModelState.Values)
            {
                foreach (ModelError error in modelState.Errors)
                {
                    _Msg = _Msg + " " + error.ErrorMessage;
                }
            }

            return(Json(new { status = false, Msg = _Msg }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult NewIndex(RegistrationExt model)
        {
            //if (SecurityUtils.IsRestrictedEmailDomainDetected(model.EmailAddress))
            //{
            //    SecurityUtils.AddAuditLog("Restricted Email Address Detected", "Restricted Email Address: " + model.EmailAddress);

            //    return RedirectToAction("RestrictedEmailDomain", "Error");
            //}
            PlayersExt pModel = MAP_Registration(model);
            string     Msg    = "";
            bool       status = true;

            ModelState.Remove("id");
            pModel.Notes = "";
            PlayersRepository modelRepo = new PlayersRepository();

            pModel.PlayerID = modelRepo.CreateOrUpdate(ref pModel, ref Msg, ref status, this, false, 0);
            if (pModel.PlayerID > 0)
            {
                ViewBag.RegSuccess = true;
            }
            else
            {
                ViewBag.RegSuccess = false;
            }
            return(View());
        }
        public ActionResult Details(PlayersExt model)
        {
            List <MessagesExt> ListOfMsgs = new List <MessagesExt>();

            string Msg    = "";
            bool   status = true;

            ModelState.Remove("id");
            ModelState.Remove("PlayerTeamID");

            if (ModelState.IsValid)
            {
                try
                {
                    PlayersRepository modelRepo = new PlayersRepository();

                    if (model.PlayerID == 0)
                    {
                        var BMI = modelRepo.CalculateBMI(model.Weight, model.HeightID);
                        model.RegBMI = BMI;
                    }

                    model.PlayerID = modelRepo.CreateOrUpdate(ref model, ref Msg, ref status, this);
                    if (status)
                    {
                        if (model.IsApply)
                        {
                            System.Web.Routing.RouteValueDictionary rt = new System.Web.Routing.RouteValueDictionary();
                            rt.Add("id", model.PlayerID);
                            rt.Add("m", SecurityUtils.EncryptText(Msg));

                            return(RedirectToAction("Details", "Players", rt));
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", Msg);
                        //BindViewBags(ref model);
                        //return View(model);
                    }
                }
                catch (Exception ex)
                {
                    string error = ErrorHandling.HandleException(ex);
                    ModelState.AddModelError("", error);
                    //BindViewBags(ref model);
                    //return View(model);
                }
            }

            {
                //Generate list of Error Messaged extracted from ModelState
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        new MessagesRepository().BuildMessageList(error.ErrorMessage, TypeOfMessage.Error, ref ListOfMsgs);
                    }
                }

                model.ListOfMsgs.AddRange(ListOfMsgs);

                BindViewBags(ref model);

                return(View(model));
            }
        }