示例#1
0
        public async Task <IActionResult> Edit(int id)
        {
            Model aircraftModel = await _models.GetModelAsync(id);

            List <Manufacturer> manufacturers = await _manufacturers.GetManufacturersAsync();

            EditModelViewModel model = _mapper.Map <EditModelViewModel>(aircraftModel);

            model.SetManufacturers(manufacturers);
            return(View(model));
        }
示例#2
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.MaxBufferSize = int.MaxValue;
            ModelClient mc = new ModelClient(binding, new EndpointAddress(new Uri(Application.Current.Host.Source, "../Silverlight/Model.svc")));

            //通过id获取详细信息    
            mc.GetModelAsync(UserID, PlayTypeID, TypeName);
            mc.GetModelCompleted += new EventHandler<GetModelCompletedEventArgs>(sc_GetModelCompleted);
        }
示例#3
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);

            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.MaxBufferSize          = int.MaxValue;
            ModelClient mc = new ModelClient(binding, new EndpointAddress(new Uri(Application.Current.Host.Source, "../Silverlight/Model.svc")));

            //通过id获取详细信息
            mc.GetModelAsync(UserID, PlayTypeID, TypeName);
            mc.GetModelCompleted += new EventHandler <GetModelCompletedEventArgs>(sc_GetModelCompleted);
        }
示例#4
0
        void sc_DelModelByIDCompleted(object sender, DelModelByIDCompletedEventArgs e)
        {
            if (e.Result < 0)
            {
                MessageBox.Show("删除失败!");

                return;
            }

            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);

            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.MaxBufferSize          = int.MaxValue;
            ModelClient mc = new ModelClient(binding, new EndpointAddress(new Uri(Application.Current.Host.Source, "../Silverlight/Model.svc")));

            //通过id获取详细信息
            mc.GetModelAsync(UserID, PlayTypeID, TypeName);
            mc.GetModelCompleted += new EventHandler <GetModelCompletedEventArgs>(sc_GetModelCompleted);
        }
示例#5
0
        /// <summary>
        /// Construct the model to confirm sighting details
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public async Task <ConfirmDetailsViewModel> GetConfirmDetailsModelAsync(string userName)
        {
            // Get the sighting, flight details and aircraft models and map them
            // into the confirm details model
            ConfirmDetailsViewModel model = new ConfirmDetailsViewModel();

            string key = GetCacheKey(SightingDetailsKeyPrefix, userName);
            SightingDetailsViewModel sighting = _cache.Get <SightingDetailsViewModel>(key);

            _mapper.Map <SightingDetailsViewModel, ConfirmDetailsViewModel>(sighting, model);

            key = GetCacheKey(FlightDetailsKeyPrefix, userName);
            FlightDetailsViewModel flight = _cache.Get <FlightDetailsViewModel>(key);

            _mapper.Map <FlightDetailsViewModel, ConfirmDetailsViewModel>(flight, model);

            key = GetCacheKey(AircraftDetailsKeyPrefix, userName);
            AircraftDetailsViewModel aircraft = _cache.Get <AircraftDetailsViewModel>(key);

            _mapper.Map <AircraftDetailsViewModel, ConfirmDetailsViewModel>(aircraft, model);

            // For the location, if we have a new location specified then use that as the
            // location. Otherwise, look up the location by its ID
            if (sighting.LocationId == 0)
            {
                model.Location = sighting.NewLocation;
            }
            else
            {
                Location location = await _locations.GetLocationAsync(sighting.LocationId);

                model.Location = location.Name;
            }

            // Repeat the above logic for the airline
            if (flight.AirlineId == 0)
            {
                model.Airline = flight.NewAirline;
            }
            else
            {
                Airline airline = await _airlines.GetAirlineAsync(flight.AirlineId);

                model.Airline = airline.Name;
            }

            // Repeat the above logic for the manufacturer
            if ((aircraft.ManufacturerId ?? 0) == 0)
            {
                model.Manufacturer = aircraft.NewManufacturer;
            }
            else
            {
                int          manufacturerId = aircraft.ManufacturerId ?? 0;
                Manufacturer manufacturer   = await _manufacturers.GetManufacturerAsync(manufacturerId);

                model.Manufacturer = manufacturer.Name;
            }

            // Repeat the above logic for the model
            if ((aircraft.ModelId ?? 0) == 0)
            {
                model.Model = aircraft.NewModel;
            }
            else
            {
                int   modelId       = aircraft.ModelId ?? 0;
                Model aircraftModel = await _models.GetModelAsync(modelId);

                model.Model = aircraftModel.Name;
            }

            return(model);
        }
示例#6
0
        void sc_DelModelByIDCompleted(object sender, DelModelByIDCompletedEventArgs e)
        {
            if (e.Result < 0)
            {
                MessageBox.Show("删除失败!");

                return;
            }

            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.MaxBufferSize = int.MaxValue;
            ModelClient mc = new ModelClient(binding, new EndpointAddress(new Uri(Application.Current.Host.Source, "../Silverlight/Model.svc")));

            //通过id获取详细信息    
            mc.GetModelAsync(UserID, PlayTypeID, TypeName);
            mc.GetModelCompleted += new EventHandler<GetModelCompletedEventArgs>(sc_GetModelCompleted);
        }