Ejemplo n.º 1
0
        public ActionResult Index(ApplyVisa AV)
        {
            Service1Client PVMS = new Service1Client();
            Country[] D = PVMS.FetchCountries();
            ViewBag.CountryDD = D.ToList();
            var username = Request.Cookies["UserName"].Value.ToString();
            int userId = DbOperation.FetchIdByUserName(username);
            AV.UserId = userId;
            if (checkForApplyVisaValidation(AV))
            {
                return View();
            }
            bool successful =DbOperation.ApplyingVisa(AV);
            if (successful)
            {
                var json = DbOperation.fetchApplyVisabyUserId(userId);
                string destination = DbOperation.fetchCountryStateCityById(json[0].CountryId);
                Session["successMsg"] = "Dear User your Visa request has been accepted successfully with id " + json[0].VisaNumber  +" ,UserId " + username + " Destination " + destination + " Employee Occupation " + json[0].Occupation + " Date of Application " + json[0].DateOfApplication.ToString("dd-MM-yyyy") + " Date of Issue " + json[0].DateOfIssue.ToString("dd-MM-yyyy") + "\n Date of Expiry " + json[0].DateOfExpiry.ToString("dd-MM-yyyy") + " Registration Cost " + json[0].RegistrationCost;

                return Redirect("/ApplyVisaSuccess");
            }
            else
            {
                return View();
            }

        }
Ejemplo n.º 2
0
        public ActionResult Index(ApplyVisa AV)
        {
            var    username = Request.Cookies["UserName"].Value.ToString();
            int    userId   = DbOperation.FetchIdByUserName(username);
            string us       = DbOperation.FetchPassportNumber(userId);
            string Visa     = DbOperation.FetchVisaNumber(userId);

            AV.VisaNumber             = Visa;
            AV.UserId                 = userId;
            Session["PassportNumber"] = us;
            if (checkForCancelVisaValidation(AV))
            {
                return(View());
            }
            bool successful = DbOperation.VisaCancel(AV);

            if (successful)
            {
                var json = DbOperation.fetchApplyVisabyUserId(userId);
                Session["successMsg"] = "Your request has been submitted successfully. Please pay " + json[0].CancellationCharge + " to complete the cancellation process";

                return(Redirect("/CancelVisaSuccess"));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 3
0
 public bool checkForCancelVisaValidation(ApplyVisa U)
 {
     if (U.DateOfIssue == null || U.DateOfIssue.ToString().Trim().Length == 0)
     {
         ModelState.AddModelError("issuedate", "Fill Date");
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 4
0
 //This method fetch the visa number while giving the userid.
 public string FetchVisaNumber(int id)
 {
     try
     {
         ApplyVisa A = PVMSModel.ApplyVisas.FirstOrDefault(x => x.UserId == id);
         return(A.VisaNumber);
     }
     catch (Exception)
     {
         return("Not Exists");
     }
 }
Ejemplo n.º 5
0
        //This mehtod check i fuser have visa number or not.
        public bool CheckUserHaveApplyVisa(int userId)
        {
            List <ApplyVisa> AP = PVMSModel.ApplyVisas.ToList();

            if (AP.Count > 0)
            {
                ApplyVisa U = PVMSModel.ApplyVisas.FirstOrDefault(x => x.UserId == userId);
                if (U != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        // GET: VisaCancellation
        //[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.CheckUserHaveApplyVisa(userId))
            {
                return(Redirect("/CancelVisaError"));
            }
            else
            {
                Session["PassportNumber"] = DbOperation.FetchPassportNumber(userId);
                Session["VisaNumber"]     = DbOperation.FetchVisaNumber(userId);

                ApplyVisa AV = new ApplyVisa();
                return(View(AV));
            }
        }
Ejemplo n.º 7
0
 // GET: ApplyVisa
 //[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("/ApplyVisaError");
     }
     else
     {
     ApplyVisa V = new ApplyVisa();
     Service1Client PVMS = new Service1Client();
     Country[] D = PVMS.FetchCountries();
     ViewBag.CountryDD = D.ToList();
     return View(V);
         
     }
 }
Ejemplo n.º 8
0
 public bool checkForApplyVisaValidation(ApplyVisa U)
 {
     if (U.CountryId == 0 || U.CountryId.ToString().Trim().Length == 0)
     {
         ModelState.AddModelError("CountryId", "Select Country");
         return true;
     }
     
     else if (U.DateOfApplication == null || U.DateOfApplication.ToString().Trim().Length == 0)
     {
         ModelState.AddModelError("DateOfApplication", "Fill Date");
         return true;
     }
     else if (U.Occupation == "-1" || U.Occupation.ToString().Trim().Length == 0)
     {
         ModelState.AddModelError("Occupation", "Select Occupation");
         return true;
     }
     else
     {
         return false;
     }
 }
Ejemplo n.º 9
0
        //This method cancel the visa while checking if user already has visa or not and generate the cancellation charge for the user and change the status in database.
        public bool CancelVisa(ApplyVisa CV)
        {
            try
            {
                ApplyVisa VA = (from c in PVMSModel.ApplyVisas
                                where c.UserId == CV.UserId && c.VisaNumber == CV.VisaNumber && c.DateOfIssue == CV.DateOfIssue
                                select c).FirstOrDefault();
                if (VA != null)
                {
                    int cancellationcost = 0;
                    int Diff_mon         = 0;
                    if (DateTime.Today < VA.DateOfExpiry)
                    {
                        Diff_mon = Math.Abs((VA.DateOfExpiry.Month - DateTime.Today.Month) + 12 * (VA.DateOfExpiry.Year - DateTime.Today.Year));
                    }
                    if (VA.Occupation == "Student")
                    {
                        if (Diff_mon < 6)
                        {
                            cancellationcost = (int)(0.15 * VA.RegistrationCost);
                        }
                        else if (Diff_mon >= 6)
                        {
                            cancellationcost = (int)(0.25 * VA.RegistrationCost);
                        }
                    }
                    else if (VA.Occupation == "Private Employee")
                    {
                        if (Diff_mon < 6)
                        {
                            cancellationcost = (int)(0.15 * VA.RegistrationCost);
                        }
                        else if (Diff_mon >= 6 && Diff_mon < 12)
                        {
                            cancellationcost = (int)(0.25 * VA.RegistrationCost);
                        }
                        else if (Diff_mon >= 12)
                        {
                            cancellationcost = (int)(0.20 * VA.RegistrationCost);
                        }
                    }
                    else if (VA.Occupation == "Government Employee")
                    {
                        if (Diff_mon >= 6 && Diff_mon < 12)
                        {
                            cancellationcost = (int)(0.20 * VA.RegistrationCost);
                        }
                        else if (Diff_mon >= 12)
                        {
                            cancellationcost = (int)(0.25 * VA.RegistrationCost);
                        }
                        else if (Diff_mon < 6)
                        {
                            cancellationcost = (int)(0.15 * VA.RegistrationCost);
                        }
                    }
                    else if (VA.Occupation == "Self Employed")
                    {
                        if (Diff_mon < 6)
                        {
                            cancellationcost = (int)(0.15 * VA.RegistrationCost);
                        }
                        else if (Diff_mon >= 6)
                        {
                            cancellationcost = (int)(0.25 * VA.RegistrationCost);
                        }
                    }
                    else if (VA.Occupation == "Retired Employee")
                    {
                        if (Diff_mon < 6)
                        {
                            cancellationcost = (int)(0.10 * VA.RegistrationCost);
                        }
                        else if (Diff_mon >= 6)
                        {
                            cancellationcost = (int)(0.20 * VA.RegistrationCost);
                        }
                    }

                    VA.CancellationCharge = cancellationcost;
                    VA.status             = "Cancelled";
                    PVMSModel.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 10
0
        //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);
            }
        }
Ejemplo n.º 11
0
        public static bool VisaCancel(ApplyVisa A)
        {
            Service1Client PVMS = new Service1Client();

            return(PVMS.CancelVisa(A));
        }
Ejemplo n.º 12
0
        public static bool ApplyingVisa(ApplyVisa A)
        {
            Service1Client PVMS = new Service1Client();

            return(PVMS.ApplyForVisa(A));
        }