Beispiel #1
0
        public async Task <ActionResult> Create(Registration registration)
        {
            try
            {
                IList <Countries> countrie = await _apiHandler.GetCountries();

                @ViewBag.ListofCountry = countrie;
                @ViewBag.ListofStates  = new List <States>();
                @ViewBag.ListofCities  = new List <Cities>();

                if (_apiHandler.ValidateEmail(registration.EmailId).Result)
                {
                    ModelState.AddModelError("EmailId", "Email Id is Already Exists");
                }
                if (!ModelState.IsValid)
                {
                    if (registration.Country == 0)
                    {
                        ModelState.AddModelError("Country", "Country is required");
                    }
                    if (registration.Country != 0)
                    {
                        @ViewBag.ListofStates = await _apiHandler.GetStatesByCountryId(registration.Country);
                    }
                    else
                    {
                        @ViewBag.ListofStates = new List <States>();
                    }

                    if (registration.State != 0)
                    {
                        @ViewBag.ListofCities = await _apiHandler.GetCitiesByStateId(registration.State);
                    }
                    else
                    {
                        @ViewBag.ListofCities = new List <Cities>();
                    }

                    return(View(registration));
                }

                var response = await _apiHandler.Registration(registration);

                Session.Message = new Message()
                {
                    CssClassName = "alert-sucess", Title = "Success!", Messages = "Candidate successfully created."
                };
                return(View());
            }
            catch
            {
                Session.Message = new Message()
                {
                    CssClassName = "alert-error", Title = "Error!", Messages = "Operation Failed."
                };
                return(View());
            }
        }