Beispiel #1
0
        //This method generates NewPassportNumber,ReIssueCost and ExpiryDate based on validations and conditions mentioned in the SRD and insert in database
        //OldPassport data is also stored in database
        public static PassportApplication PassportReIssue(PassportApplication PA)
        {
            try
            {
                string newpassportid = string.Empty;
                //Calculates ExpiryDate based on IssueDate
                DateTime expiryDate = PA.IssueDate.AddYears(10);

                //Generates PassportNumber
                if (PA.BookletType == "30 Pages")
                {
                    var fps30 = (from c in P.PassportApplications
                                 select c.PassportNumber.Substring(c.PassportNumber.Length - 4, c.PassportNumber.Length)).Max();
                    if (fps30 == null)
                    {
                        fps30 = "0";
                    }
                    newpassportid = "FPS-30" + string.Format("{0:0000}", int.Parse(fps30) + 1);
                }
                else if (PA.BookletType == "60 Pages")
                {
                    var fps60 = (from c in P.PassportApplications
                                 select c.PassportNumber.Substring(c.PassportNumber.Length - 4, c.PassportNumber.Length)).Max();
                    if (fps60 == null)
                    {
                        fps60 = "0";
                    }
                    newpassportid = "FPS-60" + string.Format("{0:0000}", int.Parse(fps60) + 1);
                }

                //Calculates ReIssueCost based on Type of Service
                int reissuecost = 0;
                if (PA.TypeOfService == "Normal")
                {
                    reissuecost = 1500;
                }
                else if (PA.TypeOfService == "Tatkal")
                {
                    reissuecost = 3000;
                }

                //Checks for the OldPassportNumber in database
                var oldpassport = (from c in P.PassportApplications
                                   where c.PassportNumber == PA.PassportNumber && c.UserID == PA.UserID
                                   select c).FirstOrDefault();
                if (oldpassport != null)
                {
                    //Removes the OldPassportData and stores in 'OldPassportData' table using trigger in SQLServer
                    P.PassportApplications.Remove(oldpassport);
                    PA.PassportNumber = newpassportid;
                    PA.ExpiryDate     = expiryDate;
                    PA.Amount         = reissuecost;

                    //Inserting New Passport details in database.
                    P.PassportApplications.Add(PA);
                    P.SaveChanges();

                    //Updates the ReasonForReIssue in 'OldPassportData' table
                    OldPassportData O = (from c in P.OldPassportDatas
                                         where c.PassportNumber == oldpassport.PassportNumber
                                         select c).FirstOrDefault();
                    O.ReasonForReIssue = PA.ReasonForReIssue;
                    P.SaveChanges();
                    return(PA);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception) { }
            return(null);
        }
Beispiel #2
0
        //This method generates VisaID,DateOfIssue,DateOfExpiry and RegistrationCost based on validations and conditions mentioned in the SRD and insert in database
        public static VisaApplication VisaApply(VisaApplication V)
        {
            try
            {
                string visaid = string.Empty;
                //Calculates DateOfIssue basedon DateOfApplication
                DateTime IssueDate        = V.DateOfApplication.AddDays(10);
                DateTime ExpiryDate       = DateTime.Today;
                int      registrationcost = 0;

                //Checks whether the User Entered PassportNumber is in database or not
                PassportApplication PA = (from c in P.PassportApplications
                                          where c.PassportNumber == V.PassportNumber
                                          select c).FirstOrDefault();
                if (PA != null)
                {
                    //Based on Occupation of the User UserID,ExpiryDate and RegistrationCost is generated
                    if (V.Occupation == "Student")
                    {
                        int student_visaid = (from c in P.VisaApplications
                                              where c.Occupation == V.Occupation
                                              select c).Count() + 1;
                        visaid     = V.Occupation.Substring(0, 3).ToUpper() + "-" + string.Format("{0:0000}", student_visaid);
                        ExpiryDate = IssueDate.AddYears(2);

                        if (V.Country == "USA")
                        {
                            registrationcost = 3000;
                        }
                        else if (V.Country == "China")
                        {
                            registrationcost = 1500;
                        }
                        else if (V.Country == "Japan")
                        {
                            registrationcost = 3500;
                        }
                    }
                    else if (V.Occupation == "Private Employee")
                    {
                        int pe_visaid = (from c in P.VisaApplications
                                         where c.Occupation == V.Occupation
                                         select c).Count() + 1;
                        visaid     = "PE-" + string.Format("{0:0000}", pe_visaid);
                        ExpiryDate = IssueDate.AddYears(3);

                        if (V.Country == "USA")
                        {
                            registrationcost = 4500;
                        }
                        else if (V.Country == "China")
                        {
                            registrationcost = 2000;
                        }
                        else if (V.Country == "Japan")
                        {
                            registrationcost = 4000;
                        }
                    }
                    else if (V.Occupation == "Government Employee")
                    {
                        int ge_visaid = (from c in P.VisaApplications
                                         where c.Occupation == V.Occupation
                                         select c).Count() + 1;
                        visaid     = "GE-" + string.Format("{0:0000}", ge_visaid);
                        ExpiryDate = IssueDate.AddYears(4);

                        if (V.Country == "USA")
                        {
                            registrationcost = 5000;
                        }
                        else if (V.Country == "China")
                        {
                            registrationcost = 3000;
                        }
                        else if (V.Country == "Japan")
                        {
                            registrationcost = 4500;
                        }
                    }
                    else if (V.Occupation == "Self Employed")
                    {
                        int se_visaid = (from c in P.VisaApplications
                                         where c.Occupation == V.Occupation
                                         select c).Count() + 1;
                        visaid     = "SE-" + string.Format("{0:0000}", se_visaid);
                        ExpiryDate = IssueDate.AddYears(1);

                        if (V.Country == "USA")
                        {
                            registrationcost = 6000;
                        }
                        else if (V.Country == "China")
                        {
                            registrationcost = 4000;
                        }
                        else if (V.Country == "Japan")
                        {
                            registrationcost = 9000;
                        }
                    }
                    else if (V.Occupation == "Retired Employee")
                    {
                        int re_visaid = (from c in P.VisaApplications
                                         where c.Occupation == V.Occupation
                                         select c).Count() + 1;
                        visaid     = "RE-" + string.Format("{0:0000}", re_visaid);
                        ExpiryDate = IssueDate.AddYears(1).AddMonths(6);

                        if (V.Country == "USA")
                        {
                            registrationcost = 2000;
                        }
                        else if (V.Country == "China")
                        {
                            registrationcost = 2000;
                        }
                        else if (V.Country == "Japan")
                        {
                            registrationcost = 1000;
                        }
                    }

                    //If ExpiryDate of Visa is after the ExpiryDate of Passport then ExpiryDate of Visa is updated to ExpiryDate of Passport
                    if (ExpiryDate > PA.ExpiryDate)
                    {
                        ExpiryDate = PA.ExpiryDate;
                    }

                    //Inserting into database
                    V.VisaID           = visaid;
                    V.DateOfIssue      = IssueDate;
                    V.DateOfExpiry     = ExpiryDate;
                    V.RegistrationCost = registrationcost;
                    P.VisaApplications.Add(V);
                    P.SaveChanges();
                    return(V);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception) { }
            return(null);
        }
Beispiel #3
0
        //This method generates PassportNumber,RegistrationCost and ExpiryDate based on validations and conditions mentioned in the SRD and insert in database
        public static PassportApplication ApplyPassport(PassportApplication PA)
        {
            try
            {
                string passportid = string.Empty;
                //Calculates ExpiryDate based on IssueDate
                DateTime expiryDate = PA.IssueDate.AddYears(10);

                //Generates PassportNumber
                if (PA.BookletType == "30 Pages")
                {
                    var fps30 = (from c in P.PassportApplications
                                 select c.PassportNumber.Substring(c.PassportNumber.Length - 4, c.PassportNumber.Length)).Max();
                    if (fps30 == null)
                    {
                        fps30 = "0";
                    }
                    passportid = "FPS-30" + string.Format("{0:0000}", int.Parse(fps30) + 1);
                }
                else if (PA.BookletType == "60 Pages")
                {
                    var fps60 = (from c in P.PassportApplications
                                 select c.PassportNumber.Substring(c.PassportNumber.Length - 4, c.PassportNumber.Length)).Max();
                    if (fps60 == null)
                    {
                        fps60 = "0";
                    }
                    passportid = "FPS-60" + string.Format("{0:0000}", int.Parse(fps60) + 1);
                }

                //Calculates RegistrationCost based on Type of Service
                int registrationcost = 0;
                if (PA.TypeOfService == "Normal")
                {
                    registrationcost = 2500;
                }
                else if (PA.TypeOfService == "Tatkal")
                {
                    registrationcost = 5000;
                }

                //Inserting into database
                PA.PassportNumber = passportid;
                PA.ExpiryDate     = expiryDate;
                PA.Amount         = registrationcost;

                int usercount = (from c in P.PassportApplications
                                 where c.UserID == PA.UserID
                                 select c).Count();
                if (usercount == 0)//Checks whether the user already registered or not
                {
                    P.PassportApplications.Add(PA);
                    P.SaveChanges();
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception) { }
            return(PA);
        }