示例#1
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     ValidateChildren();
     if (!IncorrectInputs.Any())
     {
         IRestResponse response;
         var           record = new VehicleRecord
         {
             Vin          = tbVin.Text,
             Title        = tbTitle.Text,
             Mileage      = Convert.ToInt32(tbMileage.Text),
             Description  = tbDescription.Text,
             UserId       = EnvironmentSettings.CurrentUser.Id,
             RecordTypeId = (int)cbType.SelectedValue
         };
         if (string.IsNullOrWhiteSpace(_activeRecordId))
         {
             response = ExecuteRestRequest("vehiclerecords/add", record, Method.POST, lblGeneralError, EnvironmentSettings.CurrentUser.Token);
         }
         else
         {
             response = ExecuteRestRequest($"vehiclerecords/{_activeRecordId}", record, Method.PUT, lblGeneralError, EnvironmentSettings.CurrentUser.Token);
         }
         if (response.IsSuccessful)
         {
             Close();
         }
     }
 }
示例#2
0
        public void UpdateRecord(VehicleRecord recordParam)
        {
            recordParam.Vin.Validate();
            if (!recordParam.Mileage.HasValue)
            {
                throw new AppException("Vehicle Mileage must be specified.");
            }


            var record = _context.VehicleRecords.FirstOrDefault(x => x.Id.ToString() == recordParam.Id.ToString());

            if (record == null)
            {
                throw new AppException("Record not found.");
            }

            record.Description = recordParam.Description;
            record.Mileage     = recordParam.Mileage;
            record.Vin         = recordParam.Vin;
            record.RecordType  = recordParam.RecordType;
            record.Title       = recordParam.Title;
            record.UpdateDate  = DateTime.Now;
            _context.VehicleRecords.Update(record);
            _context.SaveChanges();
        }
示例#3
0
 public RecordDetailsForm(VehicleRecord record) : this()
 {
     lblVinValue.Text         = record.Vin;
     lblMileageValue.Text     = record.Mileage.ToString("G");
     lblTitleValue.Text       = record.Title;
     lblTypeValue.Text        = record.RecordTypeStr;
     lblDescriptionValue.Text = record.Description ?? "Brak opisu";
 }
示例#4
0
        public void Create(VehicleRecord record)
        {
            record.Vin.Validate();
            if (!record.Mileage.HasValue)
            {
                throw new AppException("Vehicle Mileage must be specified.");
            }

            _context.VehicleRecords.Add(record);
            _context.SaveChanges();
        }
示例#5
0
        private VehicleRecord BuildVehicle()
        {
            VehicleRecord vehicle = new VehicleRecord()
            {
                Plate       = Plate,
                VehicleType = SelectedVehicle.VehicleType,
                Helmets     = Helmets
            };

            return(ParkingLot.AddCheckInInfoForVehicle(vehicle));
        }
示例#6
0
        public async Task SaveVehicle(VehicleRecord vehicle)
        {
            if (vehicle.Id == null)
            {
                await vehicleTable.InsertAsync(vehicle);
            }
            else
            {
                await vehicleTable.UpdateAsync(vehicle);
            }

            await SyncAsync();
        }
示例#7
0
        public static void EnterNewVehicleToGarage(Garage i_Garage)
        {
            bool isStringValid = false;

            while (isStringValid != true)
            {
                try
                {
                    string userLicenceInput = AskForNewLicenceNumber(i_Garage);
                    isStringValid = true;

                    Vehicle currentVehicle = i_Garage.GetVehicleFromGarage(userLicenceInput);
                    if (currentVehicle == null)
                    {
                        AskForVehicleBasicInput(i_Garage, ref currentVehicle, userLicenceInput);
                        VehicleRecord currentVehicleRecord = AskForOwnerInfo(i_Garage);
                        i_Garage.RecordAttachment(currentVehicle, currentVehicleRecord);
                        AskForCurrentAirPressure(currentVehicle);
                        AskForCurrentPropulsionAmount(currentVehicle);
                        if (currentVehicle is Car)
                        {
                            AskForCarExtraInput(i_Garage, ref currentVehicle);
                        }
                        else if (currentVehicle is Motorcycle)
                        {
                            AskForMotorcycleExtraInput(i_Garage, ref currentVehicle);
                        }
                        else if (currentVehicle is Truck)
                        {
                            AskForTruckExtraInput(i_Garage, ref currentVehicle);
                        }

                        i_Garage.AllGarageVehicles.Add(currentVehicle.GetHashCode(), currentVehicle);
                        Console.WriteLine("Successfully added your vehicle to the garage!");
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine(string.Format("A vehicle with an identical licence number is already in garage records "));
                        Console.WriteLine(string.Format("Owner name: {0}  owner phone number: {1}", currentVehicle.VehicleInGarageRecord.OwnersName, currentVehicle.VehicleInGarageRecord.OwnerPhoneNumber));
                        currentVehicle.VehicleInGarageRecord.CurrentVehicleStatus = VehicleRecord.eVehicleStatus.UnderRepairs;
                    }
                }
                catch (ArgumentException i_ArgumentException)
                {
                    Console.WriteLine(i_ArgumentException.Message);
                }
            }

            PressAnyKeyToContinue();
        }
示例#8
0
        public static VehicleSummary fromGovUkRecord(VehicleRecord vehicleRecord)
        {
            MOTResult lastPassedTest = vehicleRecord.motTests
                                       ?.Where(test => test.testResult == "PASSED")
                                       ?.OrderByDescending(test => test.completedDate)
                                       .First();

            return(new VehicleSummary(
                       vehicleRecord.make,
                       vehicleRecord.model,
                       vehicleRecord.primaryColour,
                       lastPassedTest?.expiryDate,
                       lastPassedTest == null ? null : Tuple.Create(lastPassedTest.odometerValue, lastPassedTest.odometerUnit)));
        }
示例#9
0
        public IActionResult AddRecord([FromBody] VehicleRecordDto recordDto)
        {
            var record = new VehicleRecord();

            record = _mapper.Map(recordDto, record);

            try
            {
                _vehicleRecordsService.Create(record);
                return(Ok());
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
示例#10
0
        public static VehicleRecord AskForOwnerInfo(Garage i_Garage)
        {
            bool          isNumber        = false;
            bool          isLength        = false;
            bool          isAllValid      = false;
            bool          isNameNotString = true;
            string        userPhoneInput  = string.Empty;
            string        userNameInput   = string.Empty;
            VehicleRecord vehicleRecord   = null;

            while (isAllValid != true)
            {
                try
                {
                    while (isNameNotString != false)
                    {
                        Console.WriteLine(string.Format("Please Enter vehicle owners name"));
                        userNameInput = Console.ReadLine();
                        i_Garage.CheckIfStringIsLetters(userNameInput);
                        isNameNotString = false;
                    }

                    while ((isNumber != true) || (isLength != true))
                    {
                        Console.WriteLine(string.Format("Please Enter vehicle owners phone number"));
                        userPhoneInput = Console.ReadLine();
                        i_Garage.CheckIfStringIsNumber(userPhoneInput);
                        isNumber = true;
                        i_Garage.PhoneIsTenChars(userPhoneInput);
                        isLength = true;
                    }

                    vehicleRecord = new VehicleRecord(userNameInput, userPhoneInput);
                    isAllValid    = true;
                }
                catch (ArgumentException i_ArgumentException)
                {
                    Console.WriteLine(i_ArgumentException.Message);
                }
            }

            return(vehicleRecord);
        }
示例#11
0
        public EditRecordForm(VehicleRecord activeRecord) : this()
        {
            tbVin.Text     = activeRecord.Vin;
            tbMileage.Text = activeRecord.Mileage.ToString();
            tbTitle.Text   = activeRecord.Title;
            var recordType = Dictionaries.GetDictionaries().FirstOrDefault(x => x.DictionaryTypeId == 1 && x.EnumValue == activeRecord.RecordTypeId);

            if (recordType != null)
            {
                foreach (dynamic item in cbType.Items)
                {
                    if (item.Id == recordType.Id)
                    {
                        cbType.SelectedItem = item;
                    }
                }
            }
            tbDescription.Text = activeRecord.Description;
            _activeRecordId    = activeRecord.Id;
        }
示例#12
0
        public Vehicle(Unit unit, VehicleRecord vehInfo, uint creatureEntry)
        {
            _me            = unit;
            _vehicleInfo   = vehInfo;
            _creatureEntry = creatureEntry;
            _status        = Status.None;
            _lastShootPos  = new Position();

            for (uint i = 0; i < SharedConst.MaxVehicleSeats; ++i)
            {
                uint seatId = _vehicleInfo.SeatID[i];
                if (seatId != 0)
                {
                    VehicleSeatRecord veSeat = CliDB.VehicleSeatStorage.LookupByKey(seatId);
                    if (veSeat != null)
                    {
                        VehicleSeatAddon addon = Global.ObjectMgr.GetVehicleSeatAddon(seatId);
                        Seats.Add((sbyte)i, new VehicleSeat(veSeat, addon));
                        if (veSeat.CanEnterOrExit())
                        {
                            ++UsableSeatNum;
                        }
                    }
                }
            }

            // Set or remove correct flags based on available seats. Will overwrite db data (if wrong).
            if (UsableSeatNum != 0)
            {
                _me.AddNpcFlag(_me.IsTypeId(TypeId.Player) ? NPCFlags.PlayerVehicle : NPCFlags.SpellClick);
            }
            else
            {
                _me.RemoveNpcFlag(_me.IsTypeId(TypeId.Player) ? NPCFlags.PlayerVehicle : NPCFlags.SpellClick);
            }

            InitMovementInfoForBase();
        }
示例#13
0
        public async Task <bool> Print(VehicleRecord vehicle)
        {
            try
            {
                var printerUrl = Settings.PrinterUrl;

                if (String.IsNullOrWhiteSpace(printerUrl))
                {
                    return(true);
                }

                using (HttpClient client = new HttpClient())
                {
                    var resolver = new DefaultContractResolver()
                    {
                        NamingStrategy = new SnakeCaseNamingStrategy()
                    };
                    var jsonSettings = new JsonSerializerSettings()
                    {
                        ContractResolver = resolver
                    };

                    string        content = JsonConvert.SerializeObject(vehicle, jsonSettings);
                    StringContent body    = new StringContent(content, Encoding.UTF8, "application/json");

                    client.Timeout = new TimeSpan(0, 0, 10);
                    var result = await client.PostAsync(printerUrl, body);

                    var data = await result.Content.ReadAsStringAsync();

                    return(result.IsSuccessStatusCode);
                }
            }
            catch
            {
                return(false);
            }
        }
示例#14
0
 private async Task <bool> Print(VehicleRecord vehicle)
 {
     return(await((PrintService)Application.Current.Resources["PrintService"]).Print(vehicle));
 }