Esempio n. 1
0
 private void StubData()
 {
     // user to create
     user = new ApplicationUser
     {
         Email    = "*****@*****.**",
         UserName = "******",
         Name     = new Name("Testor", "User")
     };
     billingAddress = new Address
     {
         StreetAddress = "Str. Brasov nr.9",
         SuiteNumber   = "3",
         City          = "Timisoara",
         Zip           = "300145"
     };
     creditCard = new CreditCard
     {
         Type             = CreditCard.CreditCardType.VISA,
         CreditCardNumber = "1234",
         NameOnCard       = "Testor User",
     };
     driverLicense = new DriverLicense
     {
         DriverLicenseNumber = "567891",
         CountryOfIssue      = "Romania"
     };
 }
Esempio n. 2
0
 public TaxiDriver(Name firstName, Name lastName, DriverLicense driverLicense)
 {
     FirstName     = firstName;
     LastName      = lastName;
     DriverLicense = driverLicense;
     DriveAction   = new Drive();
 }
Esempio n. 3
0
        internal override object[] GetRow()
        {
            MedicalCertList medicalCertList   = MedicalCertList.getInstance();
            MedicalCert     medicalCert       = medicalCertList.getItem(this);
            string          medicalCertStatus = ((medicalCert == null) || (!medicalCert.IsActual())) ? "нет" : "есть";

            LicenseList   licenseList   = LicenseList.getInstance();
            DriverLicense license       = licenseList.getItem(this);
            string        licenseStatus = ((license == null) || (!license.IsActual())) ? "нет" : "есть";

            DriverCarList driverCarList = DriverCarList.getInstance();
            Car           car           = driverCarList.GetCar(this);

            return(new object[]
            {
                Id,
                0,
                GetName(NameType.Full),
                licenseStatus,
                medicalCertStatus,
                (car == null) ? "нет автомобиля" : car.ToString(),
                Region.Name,
                CompanyName,
                Status
            });
        }
Esempio n. 4
0
 public FrmNewLicense(DriverLicense currentLicense)
 {
     InitializeComponent();
     SetTimeInterval();
     txtLicenseNumber.Text   = currentLicense.Number;
     txtLicenseCategory.Text = currentLicense.Category;
 }
Esempio n. 5
0
        public async Task <IdentityResult> CreateAsync(ApplicationUser user, DriverLicense driverLicense, Address billingAddress, CreditCard creditCard)
        {
            ThrowIfDisposed();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            if (driverLicense == null)
            {
                throw new ArgumentNullException(nameof(driverLicense));
            }

            if (billingAddress == null)
            {
                throw new ArgumentNullException(nameof(billingAddress));
            }

            if (creditCard == null)
            {
                throw new ArgumentNullException(nameof(creditCard));
            }

            // validates the user
            var validationContext = new ValidationContext(user);

            Validator.ValidateObject(user, validationContext, validateAllProperties: true);

            // validates the billing address
            validationContext = new ValidationContext(billingAddress);
            Validator.ValidateObject(billingAddress, validationContext, validateAllProperties: true);

            // validates the driver license
            validationContext = new ValidationContext(driverLicense);
            Validator.ValidateObject(driverLicense, validationContext, validateAllProperties: true);

            // validates the credit card
            validationContext = new ValidationContext(creditCard);
            Validator.ValidateObject(creditCard, validationContext, validateAllProperties: true);

            ApplicationUserManager userManager = this;
            await userManager.UpdateSecurityStampInternal(user);

            IdentityResult identityResult = await userManager.ValidateUserAsync(user);

            if (!identityResult.Succeeded)
            {
                return(identityResult);
            }
            if (userManager.Options.Lockout.AllowedForNewUsers && userManager.SupportsUserLockout)
            {
                await userManager.GetUserLockoutStore().SetLockoutEnabledAsync(user, true, userManager.CancellationToken);
            }
            await userManager.UpdateNormalizedUserNameAsync(user);

            await userManager.UpdateNormalizedEmailAsync(user);

            return(await userManager.ApplicationUserStore.CreateAsync(user, driverLicense, billingAddress, creditCard, userManager.CancellationToken));
        }
Esempio n. 6
0
        public async Task <IHttpActionResult> PutDriverLicense(int id, DriverLicense driverLicense)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != driverLicense.id)
            {
                return(BadRequest());
            }

            db.Entry(driverLicense).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DriverLicenseExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            var license1 = new DriverLicense()
            {
                Number     = "01",
                Categories = "A,B,C"
            };
            var license2 = new DriverLicense()
            {
                Number     = "02",
                Categories = "A,B,C"
            };

            license1.Number = "02";
            Console.WriteLine($"license1 == license2: {license1 == license2} \n");
            Console.ReadKey();



            var license3 = license1;

            license1.Number = "01";
            Console.WriteLine($"license1 == license3: {license1 == license3} \n");
            Console.ReadKey();



            Console.WriteLine("Moral of history:");
            Console.WriteLine("Records behave like Structs for comparisons, but be careful!");
            Console.WriteLine("Records are reference type.");

            Console.ReadKey();
        }
Esempio n. 8
0
        public async Task <ActionResult <DriverLicense> > PostDriverLicense(DriverLicense driverLicense)
        {
            //_context.DriverLicenses.Add(driverLicense);
            _context.Update(driverLicense);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDriverLicense", new { id = driverLicense.Id }, driverLicense));
        }
Esempio n. 9
0
        public async Task <bool> AddDriverLicense(DriverLicense driverLicense)
        {
            await _dataContext.DriverLicenses.AddAsync(driverLicense);

            await _dataContext.SaveChangesAsync();

            return(true);
        }
Esempio n. 10
0
        public void Delete(int idLicence)
        {
            DriverLicense licence = getItem(idLicence);

            _list.Remove(licence);

            licence.Delete();
        }
        public ActionResult DeleteConfirmed(Guid id)
        {
            DriverLicense driverLicense = db.DriverLicenses.Find(id);

            db.DriverLicenses.Remove(driverLicense);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public SerialReader(M280 M280)
 {
     m280          = M280;
     driverlicense = new DriverLicense();
     data          = new StringBuilder();
     timer         = new System.Threading.Timer(TimerExpired, this, Timeout.Infinite, Timeout.Infinite);
     Initialize();
     disposed = false;
 }
Esempio n. 13
0
        public void CreateDriverLicense()
        {
            string numberDriverLicense = "P-1111111 1";
            string dateDriverLicense   = "12/10/2020";

            var license = new DriverLicense(numberDriverLicense, dateDriverLicense);

            Assert.True(license.GetType().Equals(new DriverLicense().GetType()));
        }
Esempio n. 14
0
        public async Task <IActionResult> CreateLicence([FromBody] LicenseCreationDto licenseCreation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var driverId = User.Claims.FirstOrDefault(c => c.Type == Helpers.Constants.Strings.JwtClaimIdentifiers.DriverId)?.Value;

            var driver = _usersRepository.GetDriverById(Guid.Parse(driverId));

            if (driver == null)
            {
                return(NotFound());
            }

            if (driver?.DriverLicense != null)
            {
                var res = await _usersRepository.RemoveDriverLicense(driver.DriverLicense);

                if (!res)
                {
                    return(Conflict());
                }
            }

            DateTime licensedTo;
            DateTime licensedFrom;

            try
            {
                licensedFrom = new DateTime(licenseCreation.YearFrom, licenseCreation.MonthFrom, licenseCreation.DayFrom);
                licensedTo   = new DateTime(licenseCreation.YearTo, licenseCreation.MonthTo, licenseCreation.DayTo);
            }
            catch
            {
                return(BadRequest());
            }

            if (licensedFrom > licensedTo)
            {
                return(BadRequest());
            }
            var license = new DriverLicense()
            {
                DriverId     = Guid.Parse(driverId),
                LicensedTo   = licensedTo,
                LicensedFrom = licensedFrom
            };
            var addres = await _usersRepository.AddDriverLicense(license);

            if (!addres)
            {
                return(Conflict());
            }

            return(NoContent());
        }
Esempio n. 15
0
        private void add_Click(object sender, EventArgs e)
        {
            DriverLicense driverLicense = _driver.createDriverLicense();

            if (openAddEditDialog(driverLicense))
            {
                loadData();
            }
        }
Esempio n. 16
0
        private int Compare(DriverLicense license1, DriverLicense license2)
        {
            if (license1.DateEnd == license2.DateEnd)
            {
                return(DateTime.Compare(license1.DateBegin, license2.DateBegin) * -1);
            }

            return(DateTime.Compare(license1.DateEnd, license2.DateEnd) * -1);
        }
Esempio n. 17
0
        public void Add(DriverLicense driverLicense)
        {
            if (_list.Exists(item => item == driverLicense))
            {
                return;
            }

            _list.Add(driverLicense);
        }
Esempio n. 18
0
 public void FormControls(string CLR)
 {
     if (CLR == "CLR")
     {
         DriverID.Enabled            = false;
         DriverName.Enabled          = false;
         DriverAddress.Enabled       = false;
         Drivercity.Enabled          = false;
         DriverContact.Enabled       = false;
         DriverAge.Enabled           = false;
         DriverLicense.Enabled       = false;
         DateJoining.Enabled         = false;
         DriverSalary.Enabled        = false;
         DriverQualification.Enabled = false;
         DriverReference.Enabled     = false;
         DriverConctact2.Enabled     = false;
         DriverID.Clear();
         DriverName.Clear();
         DriverAddress.Clear();
         Drivercity.Clear();
         DriverAge.Clear();
         DriverContact.Clear();
         DriverLicense.Clear();
         DriverSalary.Clear();
         DriverQualification.Clear();
         DriverReference.Clear();
         DriverConctact2.Clear();
         DateJoining.Value = DateTime.Now;
         btnsave.Enabled   = false;
         btnedit.Enabled   = false;
         btndelete.Enabled = false;
         btnadd.Enabled    = true;
         btnfind.Enabled   = true;
         Left1.Enabled     = false;
         Right1.Enabled    = false;
     }
     if (CLR == "Save")
     {
         DriverName.Enabled          = true;
         DriverAddress.Enabled       = true;
         Drivercity.Enabled          = true;
         DriverContact.Enabled       = true;
         DriverAge.Enabled           = true;
         DriverLicense.Enabled       = true;
         DateJoining.Enabled         = true;
         DriverSalary.Enabled        = true;
         DriverQualification.Enabled = true;
         DriverReference.Enabled     = true;
         DriverConctact2.Enabled     = true;
         btnsave.Enabled             = true;
         btnadd.Enabled    = false;
         btnfind.Enabled   = false;
         btndelete.Enabled = false;
         btnedit.Enabled   = false;
     }
 }
Esempio n. 19
0
        private void FillDriverLicense()
        {
            LicenseList   licencesList  = LicenseList.getInstance();
            DriverLicense driverLicense = licencesList.getItem(_driver);

            if (driverLicense != null)
            {
                licenceInfo.Text = driverLicense.ToString();
            }
        }
Esempio n. 20
0
        protected override void loadFromSql()
        {
            DataTable dt = _provider.Select("DriverLicense");

            foreach (DataRow row in dt.Rows)
            {
                DriverLicense driverLicense = new DriverLicense(row);
                Add(driverLicense);
            }
        }
Esempio n. 21
0
        public async Task <bool> RemoveDriverLicense(DriverLicense license)
        {
            _dataContext.DriverLicenses.Remove(license);

            await _uploadService.DeleteObjectAsync(license.ImageId);

            await _dataContext.SaveChangesAsync();

            return(true);
        }
Esempio n. 22
0
        public async Task <IHttpActionResult> GetDriverLicense(int id)
        {
            DriverLicense driverLicense = await db.DriverLicenses.FindAsync(id);

            if (driverLicense == null)
            {
                return(NotFound());
            }

            return(Ok(driverLicense));
        }
Esempio n. 23
0
        private void driverLicenseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DTP dtp = _dtpList.getItem(Convert.ToInt32(_dgvDTP.Rows[_dgvDTP.SelectedCells[0].RowIndex].Cells[0].Value));

            Driver driver = _driverCarList.GetDriver(dtp.Car, dtp.Date);

            LicenseList   licencesList  = LicenseList.getInstance();
            DriverLicense driverLicense = licencesList.getItem(driver);

            WorkWithFiles.OpenFile(driverLicense.File);
        }
Esempio n. 24
0
        public async Task <IHttpActionResult> PostDriverLicense(DriverLicense driverLicense)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DriverLicenses.Add(driverLicense);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = driverLicense.id }, driverLicense));
        }
Esempio n. 25
0
        public async Task <bool> UpdateDriverLicense(DriverLicense driverLicense)
        {
            try
            {
                await _dataContext.SaveChangesAsync();
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Esempio n. 26
0
        private bool openAddEditDialog(DriverLicense driverLicense)
        {
            License_AddEdit licenseAE = new License_AddEdit(driverLicense);

            if (licenseAE.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 27
0
        public async Task UpdateDriverLicense()
        {
            StubData();

            using (var factory = new ApplicationDbContextFactory())
            {
                using (var dbContext = factory.CreateContext(false))
                {
                    using (var userStore = new ApplicationUserStore(dbContext))
                    {
                        var result = await userStore.CreateAsync(user, this.driverLicense, billingAddress, creditCard);

                        Assert.IsTrue(result.Succeeded);
                    }
                }

                DriverLicense driverLicense;
                using (var dbContext = factory.CreateContext(true))
                {
                    using (var userStore = new ApplicationUserStore(dbContext))
                    {
                        var applicationUser = await userStore.FindUserWithDriverLicenseAsync(user.Id);

                        Assert.IsNotNull(applicationUser);

                        driverLicense = new DriverLicense
                        {
                            Id = applicationUser.DriverLicenseId,
                            DriverLicenseNumber = "70001",
                            CountryOfIssue      = this.driverLicense.CountryOfIssue
                        };

                        var result = await userStore.UpdateDriverLicenseAsync(applicationUser, driverLicense);

                        Assert.IsTrue(result.Succeeded);
                    }
                }

                using (var dbContext = factory.CreateContext(false))
                {
                    var applicationUser = await dbContext.Users
                                          .Include(u => u.DriverLicense)
                                          .SingleOrDefaultAsync(u => u.UserName == user.UserName);

                    Assert.IsNotNull(applicationUser.DriverLicense);
                    Assert.IsTrue(applicationUser.DriverLicenseId == applicationUser.DriverLicense.Id);
                    Assert.IsTrue(applicationUser.DriverLicense.DriverLicenseNumber == driverLicense.DriverLicenseNumber);
                    Assert.IsTrue(applicationUser.DriverLicense.CountryOfIssue == driverLicense.CountryOfIssue);
                }
            }
        }
Esempio n. 28
0
        public async Task <IHttpActionResult> DeleteDriverLicense(int id)
        {
            DriverLicense driverLicense = await db.DriverLicenses.FindAsync(id);

            if (driverLicense == null)
            {
                return(NotFound());
            }

            db.DriverLicenses.Remove(driverLicense);
            await db.SaveChangesAsync();

            return(Ok(driverLicense));
        }
        // GET: DriverLicenses/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DriverLicense driverLicense = db.DriverLicenses.Find(id);

            if (driverLicense == null)
            {
                return(HttpNotFound());
            }
            return(View(driverLicense));
        }
Esempio n. 30
0
        private void dgvLicense_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int idDriverLicense = Convert.ToInt32(_dgvLicense.Rows[_dgvLicense.SelectedCells[0].RowIndex].Cells[0].Value);

            DriverLicense driverLicense = _licencesList.getItem(idDriverLicense);

            if ((e.ColumnIndex == 1) && (driverLicense.File != string.Empty))
            {
                tryOpenFile(driverLicense.File);
            }
            else if (openAddEditDialog(driverLicense))
            {
                loadData();
            }
        }