// GET: ReIssuePassport //[Authorize] public ActionResult Index() { if (Request.Cookies["UserName"] == null) { return(Redirect("/SignIn")); } var username = Request.Cookies["UserName"].Value.ToString(); int userId = DbOperation.FetchIdByUserName(username); if (!DbOperation.CheckUserHaveApplyPassport(userId)) { return(Redirect("/ReissuePassportError")); } else { ApplyPassport C = new ApplyPassport(); Service1Client PVMS = new Service1Client(); Country[] D = PVMS.FetchCountries(); List <SelectListItem> CountrynewList = new List <SelectListItem>(); CountrynewList.Add(new SelectListItem { Text = "Select Country", Value = "-1" }); for (var i = 0; i < D.Length; i++) { CountrynewList.Add(new SelectListItem { Text = D[i].CountryName, Value = D[i].CountryId.ToString() }); } ViewBag.CountryDD = CountrynewList.ToList(); return(View(C)); } }
public ActionResult Index(ApplyPassport A) { var username = Request.Cookies["UserName"].Value.ToString(); ViewBag.CountryDD = null; Service1Client PVMS = new Service1Client(); Country[] D = PVMS.FetchCountries(); List <SelectListItem> CountrynewList = new List <SelectListItem>(); CountrynewList.Clear(); CountrynewList.Add(new SelectListItem { Text = "Select Country", Value = "-1" }); for (var i = 0; i < D.Length; i++) { CountrynewList.Add(new SelectListItem { Text = D[i].CountryName, Value = D[i].CountryId.ToString() }); } ViewBag.CountryDD = CountrynewList.ToList(); if (checkForApplyPassportValidation(A)) { return(View()); } int userId = DbOperation.FetchIdByUserName(username); if (DbOperation.CheckUserHaveApplyPassport(userId)) { return(Redirect("/ApplyPassportError")); } else { A.UserId = userId; bool successful = DbOperation.ApplyPassportNew(A); if (successful) { var json = DbOperation.fetchApplyPassportbyUserId(userId); Session["PassportNumber"] = json[0].PassportNumber; Session["Amount"] = json[0].Amount; Session["successMsg"] = "<b>Need the passport number while giving payment? Please note down your Id \n </b> \n" + json[0].PassportNumber + ".Passport application cost is Rs." + json[0].Amount; return(Redirect("/ApplyPassportSuccess")); } else { return(View()); } } }
//This method generates NewPassportNumber based on validations and conditions mentioned and insert in database //OldPassport data is also stored in database public bool ReIssuePassport(ApplyPassport RP) { try { if (RP.BookletType.ToLower() == "60pages") { var fps30 = (from c in PVMSModel.ApplyPassports select c.PassportNumber.Substring(c.PassportNumber.Length - 4, c.PassportNumber.Length)).Max(); if (fps30 == null) { fps30 = "0"; } RP.PassportNumber = "FPS-30" + string.Format("{0:0000}", int.Parse(fps30) + 1); } if (RP.BookletType.ToLower() == "30pages") { var fps30 = (from c in PVMSModel.ApplyPassports select c.PassportNumber.Substring(c.PassportNumber.Length - 4, c.PassportNumber.Length)).Max(); if (fps30 == null) { fps30 = "0"; } RP.PassportNumber = "FPS-30" + string.Format("{0:0000}", int.Parse(fps30) + 1); } RP.ExpiryDate = GetExpiryDate(RP.IssueDate); RP.Amount = ReIssueAmount(RP.ServiceType); RP.Status = "reissuepassport"; var oldPassport = PVMSModel.ApplyPassports.FirstOrDefault(x => x.UserId == RP.UserId); if (oldPassport != null) { PVMSModel.ApplyPassports.Remove(oldPassport); PVMSModel.ApplyPassports.Add(RP); PVMSModel.SaveChanges(); OldPassportData O = PVMSModel.OldPassportDatas.FirstOrDefault(x => x.PassportNumber == oldPassport.PassportNumber); O.Reason = RP.Reason; PVMSModel.SaveChanges(); return(true); } else { return(false); } } catch (Exception) { return(false); } }
public ActionResult Index(ApplyPassport A) { var username = Request.Cookies["UserName"].Value.ToString(); ViewBag.CountryDD = null; Service1Client PVMS = new Service1Client(); Country[] D = PVMS.FetchCountries(); List <SelectListItem> CountrynewList = new List <SelectListItem>(); CountrynewList.Clear(); CountrynewList.Add(new SelectListItem { Text = "Select Country", Value = "-1" }); for (var i = 0; i < D.Length; i++) { CountrynewList.Add(new SelectListItem { Text = D[i].CountryName, Value = D[i].CountryId.ToString() }); } ViewBag.CountryDD = CountrynewList.ToList(); int userId = DbOperation.FetchIdByUserName(username); A.UserId = userId; if (checkForReissuePassportValidation(A)) { return(View()); } bool successful = DbOperation.ReissuePassport(A); if (successful) { var json = DbOperation.fetchApplyPassportbyUserId(userId); Session["PassportNumber"] = json[0].PassportNumber; Session["Amount"] = json[0].Amount; Session["successMsg"] = "<b>Passport re issue is successfully done.</b>\n Amount to be paid is Rs." + json[0].Amount + " Passport issue date is " + json[0].IssueDate.ToString("dd-MM-yyyy") + " and expiry date is " + json[0].ExpiryDate.ToString("dd-MM-yyyy"); return(Redirect("/ReIssuePassportSuccess")); } else { return(View()); } }
public bool checkForReissuePassportValidation(ApplyPassport U) { if (U.Reason == null || U.Reason.ToString().Trim().Length == 0) { ModelState.AddModelError("CountryId", "Provide Reason"); return(true); } if (U.CountryId == 0 || U.CountryId.ToString().Trim().Length == 0) { ModelState.AddModelError("CountryId", "Country can't be empty"); return(true); } else if (U.StateId == 0 || U.StateId.ToString().Trim().Length == 0) { ModelState.AddModelError("StateId", "State can't be empty"); return(true); } else if (U.CityId == 0 || U.CityId.ToString().Trim().Length == 0) { ModelState.AddModelError("CityId", "City can't be empty"); return(true); } else if (U.Pin == 0 || U.Pin.ToString().Trim().Length == 0) { ModelState.AddModelError("Pin", "Pin can't be empty"); return(true); } else if (U.Pin.ToString().Trim().Length >= 7 || U.Pin.ToString().Trim().Length <= 5) { ModelState.AddModelError("Pin", "Pin Should be of 6 Digits"); return(true); } else if (U.IssueDate == null || U.IssueDate.ToString().Trim().Length == 0) { ModelState.AddModelError("IssueDate", "Fill Date"); return(true); } else { return(false); } }
//This mehtod check wheter user have passport or not. public bool CheckUserHaveApplyPassport(int userId) { List <ApplyPassport> AP = PVMSModel.ApplyPassports.ToList(); if (AP.Count > 0) { ApplyPassport U = PVMSModel.ApplyPassports.FirstOrDefault(x => x.UserId == userId); if (U != null) { return(true); } else { return(false); } } else { return(false); } }
//This method generates PassportNumber based on validations and conditions mentioned and insert in database. public bool ApplyForPassport(ApplyPassport AP) { try { if (AP.BookletType.ToLower() == "60pages") { var fps30 = (from c in PVMSModel.ApplyPassports select c.PassportNumber.Substring(c.PassportNumber.Length - 4, c.PassportNumber.Length)).Max(); if (fps30 == null) { fps30 = "0"; } AP.PassportNumber = "FPS-30" + string.Format("{0:0000}", int.Parse(fps30) + 1); } if (AP.BookletType.ToLower() == "30pages") { var fps60 = (from c in PVMSModel.ApplyPassports select c.PassportNumber.Substring(c.PassportNumber.Length - 4, c.PassportNumber.Length)).Max(); if (fps60 == null) { fps60 = "0"; } AP.PassportNumber = "FPS-30" + string.Format("{0:0000}", int.Parse(fps60) + 1); } AP.Reason = "NA"; AP.ExpiryDate = GetExpiryDate(AP.IssueDate); AP.Amount = GetAmount(AP.ServiceType); AP.Status = "applypassport"; PVMSModel.ApplyPassports.Add(AP); PVMSModel.SaveChanges(); return(true); } catch (DbUpdateException d) { SqlException sql = (SqlException)d.GetBaseException(); string str = sql.Message; return(false); } }
// GET: ApplyPassport //[Authorize] public ActionResult Index() { if (Request.Cookies["UserName"] == null) { return(Redirect("/SignIn")); } ApplyPassport C = new ApplyPassport(); Service1Client PVMS = new Service1Client(); Country[] D = PVMS.FetchCountries(); List <SelectListItem> CountrynewList = new List <SelectListItem>(); CountrynewList.Add(new SelectListItem { Text = "Select Country", Value = "-1" }); for (var i = 0; i < D.Length; i++) { CountrynewList.Add(new SelectListItem { Text = D[i].CountryName, Value = D[i].CountryId.ToString() }); } ViewBag.CountryDD = CountrynewList.ToList(); return(View(C)); }
//This method is used for generating visa for the user and generate visa number, amount to be paid, expiry date and date of issue based on the conditon given. public bool ApplyForVisa(ApplyVisa AV) { try { AV.DateOfIssue = AV.DateOfApplication.AddDays(10); DateTime ExpiryDate = DateTime.Today; int registrationcost = 0; string ct = (from c in PVMSModel.Countries where AV.CountryId == c.CountryId select c.CountryName).FirstOrDefault(); string str = getPassportNumberByUserName(AV.UserId); if (str != null) { if (AV.Occupation.ToString() == "Student") { int student_visaid = (from c in PVMSModel.ApplyVisas where c.Occupation == AV.Occupation select c).Count() + 1; AV.VisaNumber = "STU-" + string.Format("{0:0000}", student_visaid); ExpiryDate = AV.DateOfIssue.AddYears(2); if (ct == "United States") { registrationcost = 3000; } else if (ct == "China") { registrationcost = 1500; } else if (ct == "Japan") { registrationcost = 3500; } else { registrationcost = 2500; } } else if (AV.Occupation.ToString() == "Private Employee") { int student_visaid = (from c in PVMSModel.ApplyVisas where c.Occupation == AV.Occupation select c).Count() + 1; AV.VisaNumber = "PE-" + string.Format("{0:0000}", student_visaid); ExpiryDate = AV.DateOfIssue.AddYears(3); if (ct == "United States") { registrationcost = 4500; } else if (ct == "China") { registrationcost = 2000; } else if (ct == "Japan") { registrationcost = 4000; } else { registrationcost = 3000; } } else if (AV.Occupation.ToString() == "Government Employee") { int student_visaid = (from c in PVMSModel.ApplyVisas where c.Occupation == AV.Occupation select c).Count() + 1; AV.VisaNumber = "GE-" + string.Format("{0:0000}", student_visaid); ExpiryDate = AV.DateOfIssue.AddYears(4); if (ct == "United States") { registrationcost = 5000; } else if (ct == "China") { registrationcost = 3000; } else if (ct == "Japan") { registrationcost = 4500; } else { registrationcost = 3500; } } else if (AV.Occupation.ToString() == "Self Employed") { int student_visaid = (from c in PVMSModel.ApplyVisas where c.Occupation == AV.Occupation select c).Count() + 1; AV.VisaNumber = "SE-" + string.Format("{0:0000}", student_visaid); ExpiryDate = AV.DateOfIssue.AddYears(1); if (ct == "United States") { registrationcost = 6000; } else if (ct == "China") { registrationcost = 4000; } else if (ct == "Japan") { registrationcost = 9000; } else { registrationcost = 5500; } } else if (AV.Occupation.ToString() == "Retired Employee") { int student_visaid = (from c in PVMSModel.ApplyVisas where c.Occupation == AV.Occupation select c).Count() + 1; AV.VisaNumber = "RE-" + string.Format("{0:0000}", student_visaid); ExpiryDate = AV.DateOfIssue.AddYears(1).AddMonths(6); if (ct == "United States") { registrationcost = 2000; } else if (ct == "China") { registrationcost = 2000; } else if (ct == "Japan") { registrationcost = 1000; } else { registrationcost = 1000; } } ApplyPassport PA = (from c in PVMSModel.ApplyPassports where c.ExpiryDate > ExpiryDate select c).FirstOrDefault(); if (PA != null) { ExpiryDate = PA.ExpiryDate; } AV.DateOfExpiry = ExpiryDate; AV.RegistrationCost = registrationcost; AV.status = "ApplyVisa"; PVMSModel.ApplyVisas.Add(AV); PVMSModel.SaveChanges(); return(true); } else { return(false); } } catch (Exception) { return(false); } }
public static bool ReissuePassport(ApplyPassport R) { Service1Client PVMS = new Service1Client(); return(PVMS.ReIssuePassport(R)); }
public static bool ApplyPassportNew(ApplyPassport A) { Service1Client PVMS = new Service1Client(); return(PVMS.ApplyForPassport(A)); }