Exemplo n.º 1
0
        public BoatDto GetBoatByRadioSignal(string BoatRadioSignalId)
        {
            var result = getBoatFromDb(BoatRadioSignalId);

            result.Wait();
            var entity = result.Result;

            if (entity == null)
            {
                return(null);
            }
            var dto = new BoatDto()
            {
                RegistrationId = entity.RegistrationId,
                RadioSignalId  = entity.RadioSignalId,
                Name           = entity.Name,
                Town           = entity.Town,
                State          = entity.State,
                FishingGear    = entity.FishingGear,
            };

            dto.Length = parseStrToDouble(entity.Length);
            try
            {
                dto.Weight = int.Parse(entity.Weight);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("Weight not or parsed: " + entity.Weight);
            }
            try
            {
                dto.Weight = int.Parse(entity.weight_small_boat);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("Weight not or parsed: " + entity.weight_small_boat);
            }
            try
            {
                dto.BuiltYear = int.Parse(entity.BuiltYear);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("BuiltYear not or parsed: " + entity.BuiltYear);
            }
            try
            {
                dto.EnginePower = int.Parse(entity.EnginePower);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("EnginePower not or parsed: " + entity.EnginePower);
            }
            return(dto);
        }
        public BoatDto EditBoat(BoatDto dto) => _uow.Uow(uow =>
        {
            var entity = uow.BoatRepository.Load(dto.BoatId);
            _mapper.Map(dto, entity);
            uow.BoatRepository.Edit(entity);
            uow.Save();

            return(dto);
        });
        public BoatDto AddNewBoat(BoatDto dto) => _uow.Uow(uow =>
        {
            var entity = _mapper.Map <BoatDto, Boat>(dto);
            uow.BoatRepository.Add(entity);
            uow.Save();
            dto.BoatId = entity.BoatId;

            return(dto);
        });
Exemplo n.º 4
0
        public BoatDto GetBoatByRegistration(string RegistrationId)
        {
            var boat = new BoatDto();
            var cmd  = _connection.CreateCommand();

            _connection.Open();

            cmd.CommandText = string.Format(
                @"SELECT 
                `Registreringsmerke (seddel)`,
                `Radiokallesignal (seddel)` ,
                `Fartøynavn`,
                `Fartøykommune`,
                `Fartøyfylke`,
                `Fartøynasjonalitet`,
                `Største lengde`,
                `Bruttotonnasje annen`,
                `Bruttotonnasje 1969`,
                `Byggeår`,
                `Motorkraft`,
                `Redskap`,
                `Landingsdato`
            FROM GetBoatByRegistration
            WHERE `Registreringsmerke (seddel)` = '{0}'
            ORDER BY `Landingsdato` DESC
            LIMIT 1 ", RegistrationId);
            var reader = cmd.ExecuteReader();

            using (reader)
            {
                reader.Read();
                if (reader.HasRows)
                {
                    boat.RegistrationId = reader.GetString(0);
                    boat.RadioSignalId  = reader.GetString(1);
                    boat.Name           = reader.GetString(2);
                    boat.Town           = reader.GetString(3);
                    boat.State          = reader.GetString(4);
                    boat.Nationality    = reader.GetString(5);
                    boat.Length         = reader.GetDouble(6);
                    boat.Weight         = GetBoatWeight(reader.GetInt16(7), reader.GetInt16(8));
                    boat.BuiltYear      = reader.GetInt16(9);
                    boat.EnginePower    = reader.GetInt16(10);
                    boat.FishingGear    = reader.GetString(11);
                }
            }

            _connection.Dispose();
            return(boat);
        }
        public BoatDto EditBoat([FromBody] BoatDto dto)
        {
            var editedDto = VesperLogBookService.EditBoat(dto);

            return(editedDto);
        }
        public BoatDto AddNewBoat(BoatDto dto)
        {
            var addedDto = VesperLogBookService.AddNewBoat(dto);

            return(addedDto);
        }