コード例 #1
0
        //EDIT

        public Boolean EditAirplane(Airplane airplane)
        {
            using (AirNautisEntities airNautis = new AirNautisEntities())
            {
                Airplane a = (from ap in airNautis.Airplane
                              where ap.Id == airplane.Id
                              select ap).First();

                if (airplane.Model != null && airplane.Capacity > 0 && airplane.Capacity < 1000 &&
                    airplane.Year >= 1970 && airplane.Year <= 2013)
                {
                    a.Model    = airplane.Model;
                    a.Year     = airplane.Year;
                    a.Capacity = airplane.Capacity;
                    a.Hangar   = airplane.Hangar;

                    airNautis.SaveChanges();
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        public List <Airplane> GetInactiveAirplanes()
        {
            List <Airplane> inactiveAirplanes = new List <Airplane>();

            using (AirNautisEntities airNautis = new AirNautisEntities())
            {
                var airplanes = (from a in airNautis.Airplane
                                 where a.Active == false
                                 select a);

                foreach (Airplane airplane in airplanes)
                {
                    Airplane aa = new Airplane();

                    aa.Id    = airplane.Id;
                    aa.Model = airplane.Model;


                    inactiveAirplanes.Add(aa);
                }
            }

            return(inactiveAirplanes);
        }