コード例 #1
0
ファイル: DBManager.cs プロジェクト: doorn/TreeToolApi
 /// <summary>
 /// Gets all estates from database
 /// </summary>
 /// <returns>Returns multiple estate models.</returns>
 IEnumerable<EstateModel> GetEstatesFromDB()
 {
     TreeToolOrebrollEntities ent = new TreeToolOrebrollEntities();
      var estates = (from e in ent.Estate
                     select new EstateModel
                     {
                         Name = e.Name,
                         Title = e.Title,
                         X = e.CoordiX,
                         Y =  e.CoordiY
                     });
      return estates;
 }
コード例 #2
0
        /// <summary>
        /// Gets all estates from database
        /// </summary>
        /// <returns>Returns multiple estate models.</returns>
        IEnumerable <EstateModel> GetEstatesFromDB()
        {
            TreeToolOrebrollEntities ent = new TreeToolOrebrollEntities();
            var estates = (from e in ent.Estate
                           select new EstateModel
            {
                Name = e.Name,
                Title = e.Title,
                X = e.CoordiX,
                Y = e.CoordiY
            });

            return(estates);
        }
コード例 #3
0
        //InventoryModel GetInventoryByEstateNameFromMock(int name) {
        //    return GetInventoryMockData(name);
        //}

        void SaveInventoryToDB(TreeInventoryModel inventory)
        {
            TreeToolOrebrollEntities ent = new TreeToolOrebrollEntities();



            //Estate estateEntity =  ent.Estate.Where(e => e.Name.Equals(inventory.EstateName)).Single();
            //Performer performerEntity = ent.Performer.Where(p=>p.PerformerID.Equals(inventory.PerformerID)).Single();
            //Inventory inventoryEntity = new Inventory();
            //inventoryEntity.Date = DateTime.Now;
            //inventoryEntity.Estate = estateEntity;
            //inventoryEntity.Performer = performerEntity;
            //ent.Inventory.Add(inventoryEntity);

            //ent.SaveChanges();



            // inventoryEntity.TreeObservation = "";
        }
コード例 #4
0
        /// <summary>
        /// Gets standard protocol from database.
        /// </summary>
        /// <returns>Protocol Model</returns>
        ProtocolModel GetProtocolFromDB()
        {
            TreeToolOrebrollEntities ent = new TreeToolOrebrollEntities();

            var protocol         = new ProtocolModel();
            var observationTypes = new ObservationTypeCollection();

            protocol.TreeSpecies = (ent.TreeSpecies.Select(t => new TreeSpeciesModel {
                ID = t.TreeSpeciesID, Name = t.SwedishName
            }));
            observationTypes.ActionNeedsTimeType = (ent.ActionNeedsTimeType.Select(t => new ObservationTypeModel {
                ID = t.ActionNeedsTimeID, Value = t.Value
            }));
            observationTypes.ActionNeedsType     = (ent.ActionNeedsType.Select(t => new ActionNeedsTypeModel {
                ID = t.ActionNeedsID, Value = t.Value
            }));
            observationTypes.DamageClassType     = (ent.DamageClassType.Select(t => new ObservationTypeModel {
                ID = t.DamageClassID, Value = t.Value
            }));
            observationTypes.DiseasesType        = (ent.DiseasesType.Select(t => new ObservationTypeModel {
                ID = t.DiseasesID, Value = t.Value
            }));
            observationTypes.FungusType          = (ent.FungusType.Select(t => new ObservationTypeModel {
                ID = t.FungusID, Value = t.Value
            }));
            observationTypes.SafetyType          = (ent.SafetyType.Select(t => new ObservationTypeModel {
                ID = t.SafetyID, Value = t.Value
            }));
            observationTypes.VitalityType        = (ent.VitalityType.Select(t => new ObservationTypeModel {
                ID = t.VitalityID, Value = t.Value
            }));
            observationTypes.AgeType             = (ent.AgeType.Select(t => new AgeTypeModel {
                ID = t.AgeID, Value = t.Value
            }));

            protocol.ObservationTypes = observationTypes;
            return(protocol);
        }
コード例 #5
0
ファイル: DBManager.cs プロジェクト: doorn/TreeToolApi
        //InventoryModel GetInventoryByEstateNameFromMock(int name) {
        //    return GetInventoryMockData(name);
        //}
        void SaveInventoryToDB(TreeInventoryModel inventory)
        {
            TreeToolOrebrollEntities ent = new TreeToolOrebrollEntities();

             //Estate estateEntity =  ent.Estate.Where(e => e.Name.Equals(inventory.EstateName)).Single();
             //Performer performerEntity = ent.Performer.Where(p=>p.PerformerID.Equals(inventory.PerformerID)).Single();
             //Inventory inventoryEntity = new Inventory();
             //inventoryEntity.Date = DateTime.Now;
             //inventoryEntity.Estate = estateEntity;
             //inventoryEntity.Performer = performerEntity;
             //ent.Inventory.Add(inventoryEntity);

             //ent.SaveChanges();

            // inventoryEntity.TreeObservation = "";
        }
コード例 #6
0
ファイル: DBManager.cs プロジェクト: doorn/TreeToolApi
        /// <summary>
        /// Gets standard protocol from database.
        /// </summary>
        /// <returns>Protocol Model</returns>
        ProtocolModel GetProtocolFromDB()
        {
            TreeToolOrebrollEntities ent = new TreeToolOrebrollEntities();

             var protocol = new ProtocolModel();
             var observationTypes = new ObservationTypeCollection();

             protocol.TreeSpecies = (ent.TreeSpecies.Select(t=> new TreeSpeciesModel{ ID = t.TreeSpeciesID, Name = t.SwedishName}));
             observationTypes.ActionNeedsTimeType = (ent.ActionNeedsTimeType.Select(t => new ObservationTypeModel { ID = t.ActionNeedsTimeID, Value = t.Value }));
             observationTypes.ActionNeedsType = (ent.ActionNeedsType.Select(t => new ActionNeedsTypeModel { ID = t.ActionNeedsID, Value = t.Value}));
             observationTypes.DamageClassType = (ent.DamageClassType.Select(t => new ObservationTypeModel { ID = t.DamageClassID, Value = t.Value }));
             observationTypes.DiseasesType = (ent.DiseasesType.Select(t => new ObservationTypeModel { ID = t.DiseasesID, Value = t.Value }));
             observationTypes.FungusType = (ent.FungusType.Select(t => new ObservationTypeModel { ID = t.FungusID, Value = t.Value }));
             observationTypes.SafetyType = (ent.SafetyType.Select(t => new ObservationTypeModel { ID = t.SafetyID, Value = t.Value }));
             observationTypes.VitalityType = (ent.VitalityType.Select(t => new ObservationTypeModel { ID = t.VitalityID, Value = t.Value }));
             observationTypes.AgeType = (ent.AgeType.Select(t => new AgeTypeModel { ID = t.AgeID, Value = t.Value }));

             protocol.ObservationTypes = observationTypes;
             return protocol;
        }