public ActionResult Basic() { var user = UserHelpers.GetUser(); if (user.registration_step != Constants.REG_STEP_BASIC) { return RedirectToAction("Basic", "Update"); } SetRequestURL(APIURL.BASIC_INFO_SELECT_LISTS, Method.GET); request.AddParameter("region", string.Empty); request.AddParameter("city_province", string.Empty); var response = rest.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { ViewBag.ActiveBasic = "active"; ViewBag.Label = "Create Account"; SelectCollectionsViewModel select = JsonConvert.DeserializeObject<SelectCollectionsViewModel>(response.Content); var model = new BasicViewModel() { first_name = user.first_name, middle_name = user.middle_name, last_name = user.last_name, suffix_id = user.suffix, mobile_number = user.mobile_number, birthday = DateTime.Now, issuance_date = DateTime.Now, selectList = select, resume_id = user.resume_id, id = user.id, email = user.email }; ViewBag.gender = new SelectList(model.selectList.Genders, "id", "description", model.gender); ViewBag.civil_status = new SelectList(model.selectList.CivilStatuses, "id", "description", model.civil_status); ViewBag.nationality = new SelectList(model.selectList.Nationalities, "id", "description", model.nationality); ViewBag.country = new SelectList(model.selectList.Countries, "id", "name", model.country); ViewBag.region = new SelectList(model.selectList.Regions, "id", "description", model.region); ViewBag.city_province = new SelectList(model.selectList.CityProvinces, "id", "description", model.city_province); ViewBag.zip_code = new SelectList(model.selectList.ZipCodes, "id", "code", model.zip_code); ViewBag.application_source = new SelectList(model.selectList.ApplicationSources, "id", "description", model.application_source); ViewBag.language_known = new SelectList(model.selectList.Languages, "id", "description", model.language_known); ViewBag.language_proficiency = new SelectList(model.selectList.Proficiencies, "id", "description", model.language_proficiency); ViewBag.id_type = new SelectList(model.selectList.IDs, "id", "description", model.id_type); return View(model); } else { return CustomMessage(response.Content); } }
public ActionResult Basic(BasicViewModel model) { try { ViewBag.ActiveBasic = "active"; ViewBag.Label = "Create Account"; if (model.photo != null) { if (FileHelpers.ValidImage(model.photo) == false) { ModelState.AddModelError("photo", "Please choose either a GIF, JPG or PNG image."); } } if (ModelState.IsValid) { if (model.photo != null) { model.path = FileHelpers.UploadImage(model.photo); model.photo = null; } SetRequestURL(APIURL.APPLICANT_BASIC_INFO_FORM_SUBMIT, Method.POST); request.AddBody(model); var response = rest.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { Applicant app = JsonConvert.DeserializeObject<Applicant>(response.Content); Response.SetCookie(UserHelpers.SetUser(app)); Session["NEWLY_REGISTERED"] = true; return RedirectToAction("Education"); } else { FileHelpers.DeleteFile(model.path); ModelState.AddModelError("", JsonConvert.DeserializeObject<CustomException>(response.Content).Message); } } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } SetRequestURL(APIURL.BASIC_INFO_SELECT_LISTS, Method.GET); request.AddParameter("region", model.region); request.AddParameter("city_province", model.city_province); var res = rest.Execute(request); if (res.StatusCode == HttpStatusCode.OK) { SelectCollectionsViewModel select = JsonConvert.DeserializeObject<SelectCollectionsViewModel>(res.Content); ViewBag.gender = new SelectList(select.Genders, "id", "description", model.gender); ViewBag.civil_status = new SelectList(select.CivilStatuses, "id", "description", model.civil_status); ViewBag.nationality = new SelectList(select.Nationalities, "id", "description", model.nationality); ViewBag.country = new SelectList(select.Countries, "id", "name", model.country); ViewBag.region = new SelectList(select.Regions, "id", "description", model.region); ViewBag.city_province = new SelectList(select.CityProvinces, "id", "description", model.city_province); ViewBag.zip_code = new SelectList(select.ZipCodes, "id", "code", model.zip_code); ViewBag.application_source = new SelectList(select.ApplicationSources, "id", "description", model.application_source); ViewBag.language_known = new SelectList(select.Languages, "id", "description", model.language_known); ViewBag.language_proficiency = new SelectList(select.Proficiencies, "id", "description", model.language_proficiency); ViewBag.id_type = new SelectList(select.IDs, "id", "description", model.id_type); return View(model); } else { return CustomMessage(res.Content); } }