Esempio n. 1
0
        public LicenceOptions(LicenceType licenceType)
        {
            _licenceType = licenceType;
            InitializeComponent();

            LoadLicenceDetails();
        }
    static void Main(string[] args)
    {
        Database.SetInitializer(new DropCreateDatabaseAlways <Context>());
        Context     context = new Context();
        InstalledOS os1     = new InstalledOS();

        context.InstalledOSs.Add(os1);
        LicenceType l1 = new LicenceType();

        context.LicenceTypes.Add(l1);
        Machine m1 = new Machine
        {
            InstalledOS = os1,
            LicenceType = l1
        };

        context.Machines.Add(m1);
        context.SaveChanges();
        Repository <Machine> repo = new Repository <Machine>(context.Machines);
        var     query             = repo.AllIncluding(m => m.InstalledOS, m => m.LicenceType);
        Machine m2 = query.First();

        Console.WriteLine(m2.InstalledOS.InstalledOSId);
        Console.ReadLine();
    }
Esempio n. 3
0
 //CONSTRUCTORS
 public RV(string inputName, string inputRegNumber, int inputYear,
           LicenceType inputLicence, FuelType inputFuel, decimal inputMinPrice,
           HeatingSystemType inputHS)
     : base(inputName, inputRegNumber, inputYear, inputLicence, inputFuel, inputMinPrice)
 {
     HeatingSystem = inputHS;
 }
Esempio n. 4
0
 //CONSTRUCTORS
 public Truck(string inputName, string inputRegNumber, int inputYear,
              LicenceType inputLicence, FuelType inputFuel, decimal inputMinPrice,
              uint inputWeight)
     : base(inputName, inputRegNumber, inputYear, inputLicence, inputFuel, inputMinPrice)
 {
     Weight = inputWeight;
 }
 public Licence(string registeredTo, string company, LicenceType licenceType, string numLicences, DateTime validUntil)
 {
     RegisteredTo = registeredTo;
     Company      = company;
     LicenceType  = licenceType;
     NumLicences  = numLicences;
     ValidUntil   = validUntil;
 }
Esempio n. 6
0
 //CONSTRUCTORS
 public Vehicle(string inputName, string inputRegNumber, int inputYear,
                LicenceType inputLicence, FuelType inputFuel, decimal inputMinPrice)
 {
     Name = inputName;
     RegNumber = inputRegNumber;
     _year = inputYear;
     Licence = inputLicence;
     Fuel = inputFuel;
     MinPrice = inputMinPrice;
 }
Esempio n. 7
0
        public LicenceType GetLicenceTypeByCode(string code, string lang = "en")
        {
            LicenceType type = databasePlaceholder.Get(code, lang);

            if (type == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(type);
        }
Esempio n. 8
0
 public MovieLicense(
     string movie,
     DateTime purchaseTime,
     Discount discount,
     LicenceType licenceType,
     SpecialOffer specialOffer = SpecialOffer.None)
 {
     Movie         = movie;
     PurchaseTime  = purchaseTime;
     _discount     = discount;
     _licenceType  = licenceType;
     _specialOffer = specialOffer;
 }
        public LicenceType Delete(Guid identifier)
        {
            // Load Remedy that will be deleted
            LicenceType dbEntry = context.LicenceTypes
                                  .FirstOrDefault(x => x.Identifier == identifier && x.Active == true);

            if (dbEntry != null)
            {
                // Set activity
                dbEntry.Active = false;
                // Set timestamp
                dbEntry.UpdatedAt = DateTime.Now;
            }

            return(dbEntry);
        }
        public static string GetLicenceType(LicenceType licenceType)
        {
            switch (licenceType)
            {
            case LicenceType.Academic:
                return("Academic license - for non-commercial use only");

            case LicenceType.Commercial:
                return("Commercial");

            case LicenceType.Trial:
                return("Trial - for non-commercial trial use only");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 11
0
        public static LicenceTypeViewModel ConvertToLicenceTypeViewModelLite(this LicenceType licenceType)
        {
            LicenceTypeViewModel licenceTypeViewModel = new LicenceTypeViewModel()
            {
                Id         = licenceType.Id,
                Identifier = licenceType.Identifier,

                Code        = licenceType.Code,
                Category    = licenceType.Category,
                Description = licenceType.Description,

                CreatedAt = licenceType.CreatedAt,
                UpdatedAt = licenceType.UpdatedAt
            };

            return(licenceTypeViewModel);
        }
        public void GenerateLicencePackTest()
        {
            var licenceGenerator = new LicenceGenerator();
            var serialGenerator  = SerialGeneratorFactory.GetSerialGenerator();
            var licenceValidator = new LicenceValidator(serialGenerator);

            LicenceType licenceType = LicenceType.Full;
            var         licence     = new Licence
            {
                CustomerName = "Kookdc",
                Trial        = true,
                CreationDate = DateTime.Now,
                TrialDays    = 50,
                Type         = licenceType
            };
            var licencePackString = licenceGenerator.Generate(licence, serialGenerator.Generate());
            var returnedLicence   = licenceValidator.CheckLicence(licencePackString);

            Assert.AreEqual(returnedLicence.CustomerName, licence.CustomerName);
        }
Esempio n. 13
0
 private static void ApplyLicense(this LicenceType License, string licensePath, bool ThrowExIfExpired, CodeToApplyLicense ApplyLicenseCode)
 {
     try
     {
         using (Lic lic = new Lic(License, licensePath))
         {
             if (lic != null)
             {
                 if (lic.CanApply)
                 {
                     if (ApplyLicenseCode != null)
                     {
                         ApplyLicenseCode(lic.LicenseStream);
                     }
                     else
                     {
                         throw new Exception("Delegate ApplyLicenseCode of type CodeToApplyLicense is null");
                     }
                 }
             }
         }
     }
     catch (InvalidOperationException IoEx)
     {
         if (IoEx.Message.ToLowerInvariant().Contains("expired"))
         {
             if (ThrowExIfExpired)
             {
                 throw new Exception("The Aspose license has expired.", IoEx);
             }
         }
         else
         {
             throw new Exception("InvalidOperationException on applying Aspose license!", IoEx);
         }
     }
     catch (System.Exception ex)
     {
         throw new Exception("Generic Exception on applying Aspose license!", ex);
     }
 }
Esempio n. 14
0
 public Lic(LicenceType License, string licensePath)
 {
     try
     {
         switch (License)
         {
         case LicenceType.Production:
             LicenseStream = new MemoryStream(File.ReadAllBytes(licensePath));
             if (CheckLicenceStream(LicenseStream, "Aspose_Total"))
             {
                 CanApply = true;
             }
             break;
         }
     }
     catch (System.Exception ex)
     {
         CanApply = false;
         throw new System.Exception("Loading Aspose license error!", ex);
     }
 }
Esempio n. 15
0
        public async Task <ActionResult <LicenceType> > PostLicenceType(LicenceTypeInputDto input)
        {
            try
            {
                var licenceType = new LicenceType()
                {
                    Name          = input.Name,
                    ArabicName    = input.ArabicName,
                    CreatedDate   = DateTime.Now,
                    CreatedUserId = input.UserId
                };
                _context.LicenceTypes.Add(licenceType);
                await _context.SaveChangesAsync();

                return(licenceType);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public LicenceTypeResponse Create(LicenceTypeViewModel licenceType)
        {
            LicenceTypeResponse response = new LicenceTypeResponse();

            try
            {
                LicenceType addedLicenceType = unitOfWork.GetLicenceTypeRepository().Create(licenceType.ConvertToLicenceType());
                unitOfWork.Save();

                response.LicenceType = addedLicenceType.ConvertToLicenceTypeViewModel();
                response.Success     = true;
            }
            catch (Exception ex)
            {
                response.LicenceType = new LicenceTypeViewModel();
                response.Success     = false;
                response.Message     = ex.Message;
            }

            return(response);
        }
        public IActionResult LicenceCreate(CreateLicenceViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            LicenceType licenceType = _licenceProvider.LicenceTypesGet().Where(l => l.Id == model.LicenceType).FirstOrDefault();

            if (licenceType == null)
            {
                ModelState.AddModelError(String.Empty, Languages.LanguageStrings.LicenceTypeInvalid);
            }

            if (ModelState.IsValid)
            {
                switch (_licenceProvider.LicenceTrialCreate(UserId(), licenceType))
                {
                case Middleware.LicenceCreate.Existing:
                    GrowlAdd(String.Format(Languages.LanguageStrings.LicenceCreateTrialExists,
                                           licenceType.Description));
                    break;

                case Middleware.LicenceCreate.Failed:
                    GrowlAdd(Languages.LanguageStrings.LicenceCreateTrialFailed);
                    break;

                case Middleware.LicenceCreate.Success:
                    GrowlAdd(Languages.LanguageStrings.LicenceCreatedTrial);
                    break;
                }

                return(RedirectToAction(nameof(Licences)));
            }

            model.Breadcrumbs = GetBreadcrumbs();
            model.CartSummary = GetCartSummary();

            return(View(model));
        }
        public LicenceType Create(LicenceType licenceType)
        {
            if (context.LicenceTypes.Where(x => x.Identifier != null && x.Identifier == licenceType.Identifier).Count() == 0)
            {
                licenceType.Id = 0;

                licenceType.Code   = GetNewCodeValue(licenceType.CompanyId ?? 0);
                licenceType.Active = true;

                licenceType.UpdatedAt = DateTime.Now;
                licenceType.CreatedAt = DateTime.Now;

                context.LicenceTypes.Add(licenceType);
                return(licenceType);
            }
            else
            {
                // Load Sector that will be updated
                LicenceType dbEntry = context.LicenceTypes
                                      .FirstOrDefault(x => x.Identifier == licenceType.Identifier && x.Active == true);

                if (dbEntry != null)
                {
                    dbEntry.CountryId   = licenceType.CountryId ?? null;
                    dbEntry.CompanyId   = licenceType.CompanyId ?? null;
                    dbEntry.CreatedById = licenceType.CreatedById ?? null;

                    // Set properties
                    dbEntry.Code     = licenceType.Code;
                    dbEntry.Category = licenceType.Category;

                    dbEntry.Description = licenceType.Description;

                    // Set timestamp
                    dbEntry.UpdatedAt = DateTime.Now;
                }

                return(dbEntry);
            }
        }
Esempio n. 19
0
 public static void RegWordsLibrary(LicenceType License, string licensePath, bool ThrowExIfExpired)
 {
     try
     {
         License.ApplyLicense(licensePath, ThrowExIfExpired, lic =>
         {
             global::Aspose.Words.License TypedLicense = new global::Aspose.Words.License();
             if (TypedLicense != null)
             {
                 TypedLicense.SetLicense(lic);
             }
             else
             {
                 throw new Exception("Typed Licence Aspose.Words is null");
             }
         });
     }
     catch (System.Exception ex)
     {
         throw new System.Exception("Generic Exception on Create and Set Aspose.Words.License", ex);
     }
 }
Esempio n. 20
0
        public static LicenceType ConvertToLicenceType(this LicenceTypeViewModel licenceTypeViewModel)
        {
            LicenceType licenceType = new LicenceType()
            {
                Id         = licenceTypeViewModel.Id,
                Identifier = licenceTypeViewModel.Identifier,

                Code        = licenceTypeViewModel.Code,
                Category    = licenceTypeViewModel.Category,
                Description = licenceTypeViewModel.Description,


                CountryId   = licenceTypeViewModel.Country?.Id ?? null,
                CreatedById = licenceTypeViewModel.CreatedBy?.Id ?? null,
                CompanyId   = licenceTypeViewModel.Company?.Id ?? null,

                CreatedAt = licenceTypeViewModel.CreatedAt,
                UpdatedAt = licenceTypeViewModel.UpdatedAt
            };

            return(licenceType);
        }
        public LicenceTypeResponse Delete(Guid identifier)
        {
            LicenceTypeResponse response = new LicenceTypeResponse();

            try
            {
                LicenceType deletedLicenceType = unitOfWork.GetLicenceTypeRepository().Delete(identifier);

                unitOfWork.Save();

                response.LicenceType = deletedLicenceType.ConvertToLicenceTypeViewModel();
                response.Success     = true;
            }
            catch (Exception ex)
            {
                response.LicenceType = new LicenceTypeViewModel();
                response.Success     = false;
                response.Message     = ex.Message;
            }

            return(response);
        }
Esempio n. 22
0
        public IActionResult LicenceCreate(CreateLicenceViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            LicenceType licenceType = _licenceProvider.LicenceTypesGet().Where(l => l.Id == model.LicenceType).FirstOrDefault();

            if (licenceType == null)
            {
                ModelState.AddModelError(String.Empty, "Invalid Licence Type");
            }

            if (ModelState.IsValid)
            {
                switch (_licenceProvider.LicenceTrialCreate(UserId(), licenceType))
                {
                case Middleware.LicenceCreate.Existing:
                    GrowlAdd($"You already have a trial licence for {licenceType.Description}");
                    break;

                case Middleware.LicenceCreate.Failed:
                    GrowlAdd("Failed to create a trial licence");
                    break;

                case Middleware.LicenceCreate.Success:
                    GrowlAdd("Trial licence succesfully created");
                    break;
                }

                return(RedirectToAction(nameof(Licences)));
            }

            return(View(model));
        }
Esempio n. 23
0
        public static LicenceTypeViewModel ConvertToLicenceTypeViewModel(this LicenceType licenceType)
        {
            LicenceTypeViewModel licenceTypeViewModel = new LicenceTypeViewModel()
            {
                Id         = licenceType.Id,
                Identifier = licenceType.Identifier,

                Code        = licenceType.Code,
                Category    = licenceType.Category,
                Description = licenceType.Description,

                Country = licenceType.Country?.ConvertToCountryViewModelLite(),

                IsActive = licenceType.Active,

                CreatedBy = licenceType.CreatedBy?.ConvertToUserViewModelLite(),
                Company   = licenceType.Company?.ConvertToCompanyViewModelLite(),

                UpdatedAt = licenceType.UpdatedAt,
                CreatedAt = licenceType.CreatedAt
            };

            return(licenceTypeViewModel);
        }
Esempio n. 24
0
 //CONSTRUCTORS
 public CarPrivate(string inputName, string inputRegNumber, int inputYear,
                   LicenceType inputLicence, FuelType inputFuel, decimal inputMinPrice)
     : base(inputName, inputRegNumber, inputYear, inputLicence, inputFuel, inputMinPrice)
 {
 }
Esempio n. 25
0
        /// <summary>
        /// Get all Licences
        /// </summary>
        /// <returns></returns>
        private static List <Licence> GetAllLicences(LicenceType type, bool?enabled = null)
        {
            List <Licence> Licences = new List <Licence>();
            string         sWHERE   = " WHERE ";
            string         sAND     = string.Empty;
            string         sql      = "SELECT ExePath, Type, TimeInterval,MaxTime, ConcurrentLicences ,LastRunStart,LastRunEnd  , Enabled FROM " + TABLE_NAME;

            switch (type)
            {
            case LicenceType.TRIGGERBASE:
                sql    = sql + sWHERE + sAND + " Type = 'TRIGGERBASE' ";
                sWHERE = string.Empty;
                sAND   = " AND ";
                break;

            case LicenceType.PERIODIC:
                sql    = sql + sWHERE + sAND + " Type = 'PERIODIC' ";
                sWHERE = string.Empty;
                sAND   = " AND ";
                break;

            case LicenceType.NONE:
                break;
            }
            if (enabled.HasValue)
            {
                if (enabled.Value)
                {
                    sql = sql + sWHERE + sAND + " Enabled = '1'";
                }
                else
                {
                    sql = sql + sWHERE + sAND + " Enabled = '0'";
                }

                sWHERE = string.Empty;
                sAND   = " AND ";
            }
            System.Data.DataSet transData = SqliteDbHelper.GetData(sql);
            if (transData != null)
            {
                if (transData.Tables.Count > 0)
                {
                    if (transData.Tables[0].Rows.Count > 0)
                    {
                        foreach (System.Data.DataRow dr in transData.Tables[0].Rows)
                        {
                            Licence Licence = new Licence(SqliteDbHelper.ToString(dr["ExePath"]));

                            Licence.Type               = (LicenceType)Enum.Parse(typeof(LicenceType), SqliteDbHelper.ToString(dr["Type"]));
                            Licence.TimeInterval       = SqliteDbHelper.ToInt(dr["TimeInterval"]);
                            Licence.MaxTime            = SqliteDbHelper.ToInt(dr["MaxTime"]);
                            Licence.ConcurrentLicences = SqliteDbHelper.ToInt(dr["ConcurrentLicences"]);
                            Licence.LastRunStart       = SqliteDbHelper.ToNullableDateTime(dr["LastRunStart"]);
                            Licence.LastRunEnd         = SqliteDbHelper.ToNullableDateTime(dr["LastRunEnd"]);
                            Licence.Enabled            = SqliteDbHelper.ToBoolean(dr["Enabled"]);
                            Licences.Add(Licence);
                        }
                    }
                }
            }
            return(Licences);
        }
        public List <LicenceType> GetLicenceTypes(int companyId)
        {
            List <LicenceType> LicenceTypes = new List <LicenceType>();

            string queryString =
                "SELECT LicenceTypeId, LicenceTypeIdentifier, LicenceTypeCode, Category, Description, " +
                "CountryId, CountryIdentifier, CountryCode, CountryName, " +
                "Active, UpdatedAt, CreatedById, CreatedByFirstName, CreatedByLastName, CompanyId, CompanyName " +
                "FROM vLicenceTypes " +
                "WHERE CompanyId = @CompanyId AND Active = 1;";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = connection.CreateCommand();
                command.CommandText = queryString;
                command.Parameters.Add(new SqlParameter("@CompanyId", companyId));

                connection.Open();
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    LicenceType licenceType;
                    while (reader.Read())
                    {
                        licenceType             = new LicenceType();
                        licenceType.Id          = Int32.Parse(reader["LicenceTypeId"].ToString());
                        licenceType.Identifier  = Guid.Parse(reader["LicenceTypeIdentifier"].ToString());
                        licenceType.Code        = reader["LicenceTypeCode"].ToString();
                        licenceType.Category    = reader["Category"]?.ToString();
                        licenceType.Description = reader["Description"]?.ToString();

                        if (reader["CountryId"] != DBNull.Value)
                        {
                            licenceType.Country            = new Country();
                            licenceType.CountryId          = Int32.Parse(reader["CountryId"].ToString());
                            licenceType.Country.Id         = Int32.Parse(reader["CountryId"].ToString());
                            licenceType.Country.Identifier = Guid.Parse(reader["CountryIdentifier"].ToString());
                            licenceType.Country.Mark       = reader["CountryCode"].ToString();
                            licenceType.Country.Name       = reader["CountryName"].ToString();
                        }

                        licenceType.Active    = bool.Parse(reader["Active"].ToString());
                        licenceType.UpdatedAt = DateTime.Parse(reader["UpdatedAt"].ToString());

                        if (reader["CreatedById"] != DBNull.Value)
                        {
                            licenceType.CreatedBy           = new User();
                            licenceType.CreatedById         = Int32.Parse(reader["CreatedById"].ToString());
                            licenceType.CreatedBy.Id        = Int32.Parse(reader["CreatedById"].ToString());
                            licenceType.CreatedBy.FirstName = reader["CreatedByFirstName"]?.ToString();
                            licenceType.CreatedBy.LastName  = reader["CreatedByLastName"]?.ToString();
                        }

                        if (reader["CompanyId"] != DBNull.Value)
                        {
                            licenceType.Company      = new Company();
                            licenceType.CompanyId    = Int32.Parse(reader["CompanyId"].ToString());
                            licenceType.Company.Id   = Int32.Parse(reader["CompanyId"].ToString());
                            licenceType.Company.Name = reader["CompanyName"].ToString();
                        }

                        LicenceTypes.Add(licenceType);
                    }
                }
            }
            return(LicenceTypes);

            //List<LicenceType> licenceTypes = context.LicenceTypes
            //    .Include(x => x.Country)
            //    .Include(x => x.Company)
            //    .Include(x => x.CreatedBy)
            //    .Where(x => x.Active == true && x.CompanyId == companyId)
            //    .OrderByDescending(x => x.CreatedAt)
            //    .AsNoTracking()
            //    .ToList();

            //return licenceTypes;
        }
        /// <summary>
        /// Checks for licence eligibility given a number of driver inputs
        /// </summary>
        /// <param name="licenceType">The Licence Type, reference to the LicenceType enum</param>
        /// <param name="dvla">Boolean as to whether the driver has a full DVLA licence</param>
        /// <param name="licenceTerm">The number of years for the renewal</param>
        /// <param name="dateOfBirth">The date of birth of the driver</param>
        /// <returns></returns>
        public static LicenceEligibilityResponse CheckLicenceEligibility(LicenceType licenceType, bool dvla, int licenceTerm, DateTime dateOfBirth)
        {
            // Validate method inputs
            if (!Enum.IsDefined(typeof(LicenceType), licenceType))
            {
                throw new ArgumentException();
            }
            if (licenceTerm != 1 && licenceTerm != 2 && licenceTerm != 3)
            {
                throw new ArgumentException();
            }

            var builder       = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
            var configuration = builder.Build();

            // Get some initial configuration settings
            int    minimumAge             = int.Parse(configuration["minimum_age"]);
            double newLicenceCost         = double.Parse(configuration["new_licence_fee"]);
            double licenceAnnualFee       = double.Parse(configuration["licence_annual_fee"]);
            double oneTermDiscount        = double.Parse(configuration["one_term_discount"]);
            double twoTermDiscount        = double.Parse(configuration["two_term_discount"]);
            double threeTermDiscount      = double.Parse(configuration["three_term_discount"]);
            string responseAgeInvalid     = configuration["response_age_invalid"];
            string responseDVLARequired   = configuration["response_dvla_required"];
            string responseLicenceCost    = configuration["response_licence_cost"];
            string responseNewLicenceCost = configuration["response_new_licence_cost"];
            string responseDiscount       = configuration["response_discount"];
            string responseTotal          = configuration["response_total"];

            LicenceEligibilityResponse response = new LicenceEligibilityResponse();
            var    messages = new List <string>();
            var    costs    = new List <string>();
            double total    = 0.00;
            double discount = 0.00;

            response.success = true;

            // 1. First validate the date of birth
            int age = DateTime.Now.Year - dateOfBirth.Year;

            if (dateOfBirth > DateTime.Now.AddYears(-age))
            {
                age--;
            }
            if (age < minimumAge)
            {
                response.success = false;
                messages.Add(String.Format(responseAgeInvalid, minimumAge.ToString()));
            }

            // 2. Then validate the DVLA licence
            if (!dvla)
            {
                response.success = false;
                messages.Add(String.Format(responseDVLARequired));
            }

            // 3. Calculate the cost of the licence
            double licenceCost = licenceAnnualFee * licenceTerm;

            total = total + licenceCost;
            costs.Add(String.Format(responseLicenceCost, licenceCost.ToString("0.00"), licenceTerm.ToString(), licenceAnnualFee));

            // 4. If a new licence add on that cost
            if (licenceType == LicenceType.New)
            {
                total = total + newLicenceCost;
                costs.Add(String.Format(responseNewLicenceCost, newLicenceCost.ToString("0.00")));
            }

            // 4. Apply any discount
            if (licenceTerm == 1 && oneTermDiscount > 0.00)
            {
                discount = (total * oneTermDiscount);
                total    = total - discount;
                costs.Add(String.Format(responseDiscount, discount.ToString("0.00"), "1"));
            }
            if (licenceTerm == 2 && twoTermDiscount > 0.00)
            {
                discount = (total * twoTermDiscount);
                total    = total - discount;
                costs.Add(String.Format(responseDiscount, discount.ToString("0.00"), "2"));
            }
            if (licenceTerm == 3 && threeTermDiscount > 0.00)
            {
                discount = (total * threeTermDiscount);
                total    = total - discount;
                costs.Add(String.Format(responseDiscount, discount.ToString("0.00"), "3"));
            }

            // Also add the total
            costs.Add(String.Format(responseTotal, total.ToString("0.00")));

            response.messages = messages;
            response.costs    = costs;
            response.total    = total;
            return(response);
        }
Esempio n. 28
0
 //CONSTRUCTORS
 public CarCommercial(string inputName, string inputRegNumber, int inputYear,
                      LicenceType inputLicence, FuelType inputFuel, decimal inputMinPrice)
     : base(inputName, inputRegNumber, inputYear, inputLicence, inputFuel, inputMinPrice)
 {
     _towBar = true;
 }
Esempio n. 29
0
 public Task <LicenceType> UpdateLicenceTypeAsync(LicenceType licenceType)
 {
     throw new NotImplementedException();
 }
Esempio n. 30
0
 /*! \brief Set the licence type used in the %ProgInfo Dialogue.
  * \note The \e LicenceType property can be used for the same purpose.  */
 public void SetLicence(LicenceType type)
 {
     MiscOp_SetR3(0, Method.SetLicenceType, (uint)type);
 }
Esempio n. 31
0
        /// <summary>
        /// The main entry point of the application. Takes in user input for the licence application
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            // Application Configuration
            var    builder                 = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
            var    configuration           = builder.Build();
            string questionExistingLicence = configuration["question_existing_licence"];
            string questionLicenceTerm     = configuration["question_licence_term"];
            string questionDVLAHeld        = configuration["question_dvla_held"];
            string questionDateOfBirth     = configuration["question_date_of_birth"];

            // Inputs to eligibility check. Licence Type, Term,
            LicenceType type = LicenceType.New;
            int         term = 1;
            bool        dvla = false;
            DateTime    dob;

            // Licence Type Input
            ConsoleKey renewal_response;

            do
            {
                Console.Write(questionExistingLicence);
                renewal_response = Console.ReadKey(false).Key;
                if (renewal_response != ConsoleKey.Enter)
                {
                    Console.WriteLine();
                }
            } while (renewal_response != ConsoleKey.Y && renewal_response != ConsoleKey.N);

            // Renewal Term Input
            if (renewal_response == ConsoleKey.Y)
            {
                type = LicenceType.Renewal;
                ConsoleKeyInfo termResponse;
                do
                {
                    Console.Write(questionLicenceTerm);
                    termResponse = Console.ReadKey(false);
                    if (termResponse.Key != ConsoleKey.Enter)
                    {
                        Console.WriteLine();
                    }
                } while (termResponse.Key != ConsoleKey.D1 && termResponse.Key != ConsoleKey.D2 && termResponse.Key != ConsoleKey.D3);
                term = (int)char.GetNumericValue(termResponse.KeyChar);
            }

            // DVLA Licence Input
            ConsoleKey dvla_held;

            do
            {
                Console.Write(questionDVLAHeld);
                dvla_held = Console.ReadKey(false).Key;
                if (dvla_held != ConsoleKey.Enter)
                {
                    Console.WriteLine();
                }
            } while (dvla_held != ConsoleKey.Y && dvla_held != ConsoleKey.N);
            dvla = (dvla_held == ConsoleKey.Y ? true : false);

            // DOB Input
            string dob_response;

            string[] formats = { "dd/MM/yyyy" };
            do
            {
                Console.Write(questionDateOfBirth);
                dob_response = Console.ReadLine();
            } while (!DateTime.TryParseExact(dob_response, formats, CultureInfo.InvariantCulture, DateTimeStyles.None, out dob));

            var response = LicenceApplication.CheckLicenceEligibility(type, dvla, term, dob);

            // Print out the response - different formatting if success or rejection
            if (response.success)
            {
                Console.Write("\n");
                Console.Write("------------------------------------------------\n");
                Console.Write("--------- Eligible for Taxi Licence ------------\n");
                Console.Write("------------------------------------------------\n");
                Console.Write("\n");
                Console.Write("Costs: \n");

                for (int i = 0; i < response.costs.Count; i++)
                {
                    Console.Write(response.costs[i] + "\n");
                }
            }
            else
            {
                Console.Write("\n");
                Console.Write("------------------------------------------------\n");
                Console.Write("--------- NOT Eligible for Taxi Licence --------\n");
                Console.Write("------------------------------------------------\n");
                Console.Write("\n");
                Console.Write("Reasons: \n");

                for (int i = 0; i < response.messages.Count; i++)
                {
                    Console.Write(response.messages[i] + "\n");
                }
            }

            // Keep application alive
            Console.WriteLine("\nPress any key to exit...");
            Console.ReadKey();
        }