コード例 #1
0
        public IHttpActionResult UserInitialInfoForm(long id)
        {
            try
            {
                SelectRepository selectRepo = new SelectRepository();
                AltPrimaryViewModel model = new AltPrimaryViewModel(repo.GetInitialInfo(id));

                model.lstSuffixes = selectRepo.Suffixes();

                return Ok(model);
            }
            catch (Exception ex)
            {
                return BadRequest(ex.Message);
            }
        }
コード例 #2
0
        public ActionResult Index(AltPrimaryViewModel model)
        {
            try
            {
                ViewBag.ActiveProfile = "active";
                ModelState.Remove("email");

                if (ModelState.IsValid)
                {
                    SetRequestURL(APIURL.APPLICANT_INITIAL_FORM_SUBMIT, Method.POST);
                    request.AddBody(model);
                    var response = rest.Execute(request);

                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        Applicant app = JsonConvert.DeserializeObject<Applicant>(response.Content);
                        SetMessage(Success.INITIAL_UPDATE, MESSAGE_TYPE.SUCCESS);

                        if (app.registration_step == Constants.REG_STEP_BASIC)
                        {
                            return RedirectToAction("Basic", "Profile");
                        }
                        else
                        {
                            return RedirectToAction("Index", "Profile");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", JsonConvert.DeserializeObject<CustomException>(response.Content).Message);
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
            }

            SetRequestURL(APIURL.SUFFIXES, Method.GET);
            var res = rest.Execute(request);

            if (res.StatusCode == HttpStatusCode.OK)
            {
                SelectCollectionsViewModel selectModel = JsonConvert.DeserializeObject<SelectCollectionsViewModel>(res.Content);
                ViewBag.suffix_id = new SelectList(selectModel.suffixes, "suffix", "suffix", model.suffix_id);
                return View("Index", model);
            }
            else
            {
                return CustomMessage(res.Content);
            }
        }