public ActionResult Create(FormCollection form, CreateDealerInput input, HttpPostedFileBase tin_file, HttpPostedFileBase bl_file) { if (ModelState.IsValid) { if (tin_file != null && bl_file != null) { } var user = _userAppService.GetLoggedInUser(); input.StationId = user.StationId; //get user logged in station int Id = _dealerAppService.CreateDealer(input); //update selected candidate if exists if (form.AllKeys.Contains("CandidateId") && !string.IsNullOrEmpty(form.Get("CandidateId").ToString())) { var candidate = _candidateAppService.GetCandidate(Convert.ToInt32(form.Get("CandidateId"))); _candidateAppService.RegisterCandidate(candidate); } return(RedirectToAction("Create", "DealerActivities", new { id = Id })); } else { var stations = _stationAppService.GetStations().Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }); ViewBag.StationId = stations; return(View()); } }
public ActionResult ApplyForRegistration(CreateDealerInput input) { try { if (ModelState.IsValid) { if (_dealerAppService.IsApplicationExists(input.ApplicantId, _financialYearAppService.GetActiveFinancialYear())) { TempData["danger"] = string.Format(@"Your have already submitted application for current financial year ""{0}"" !", _financialYearAppService.GetActiveFinancialYear().Name); return(RedirectToAction("Index", "Dashboard")); } else { int DealerId = _dealerAppService.CreateDealer(input); TempData["success"] = string.Format(@"The Application has been successfully created!."); return(RedirectToAction("AddActivities", new { Id = DealerId })); } } else { var applicant = _applicantService.GetApplicantById(_userAppService.GetLoggedInUser().ApplicantId); var Station = _stationAppService.GetStations().Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }); ViewBag.Applicant = applicant; ViewBag.StationId = Station; ViewBag.SerialNumber = RandomSerialNumbers(); return(View()); } }catch (Exception ex) { var applicant = _applicantService.GetApplicantById(_userAppService.GetLoggedInUser().ApplicantId); var Station = _stationAppService.GetStations().Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }); ViewBag.Applicant = applicant; ViewBag.StationId = Station; ViewBag.SerialNumber = RandomSerialNumbers(); ModelState.AddModelError("danger", ex.Message); return(View()); } }