Esempio n. 1
0
        public static async Task <Models.ModelCatalog> FindOrCreateModelCatalogAsync
        (
            this CarContext carContext,
            string makeName,
            string modelName)
        {
            var query        = @"EXECUTE [dbo].[FindOrCreateModelCatalog] 
                           @MakeName
                          ,@ModelName
                          ,@Id OUTPUT";
            var parMakeName  = CarContextExtentions.CreateParNVarchar("@MakeName", makeName, 255);
            var parModelName = CarContextExtentions.CreateParNVarchar("@ModelName", modelName, 255);
            var parId        = CarContextExtentions.ParIdOutput();

            carContext.Database.ExecuteSqlRaw(
                query,
                parMakeName,
                parModelName,
                parId);

            var model = new Models.ModelCatalog
            {
                Id   = (Guid)parId.Value,
                Name = modelName
            };

            return(model);
        }
        public static async Task <FeatureCatalog> FindOrCreateFeatureCatalogAsync(
            this CarContext carContext,
            Guid descriptionCatalogId,
            string name,
            bool?standart,
            string value)
        {
            var query = @"EXECUTE [dbo].[FindOrCreateFeatureCatalog] 
                          @DescriptionCatalogId,
                          @Name,
                          @Standart,
                          @Value";

            var parDescId   = CarContextExtentions.CreateParGuid("@DescriptionCatalogId", descriptionCatalogId);
            var parName     = CarContextExtentions.ParNameInput(name);
            var parStandart = CarContextExtentions.CreateParBit("@Standart", standart);
            var parValue    = CarContextExtentions.CreateParNVarchar("@Value", value, 250);

            return(carContext.FeatureCatalog.FromSqlRaw(
                       query,
                       parDescId,
                       parName,
                       parStandart,
                       parValue
                       ).AsEnumerable().First());
        }
Esempio n. 3
0
        public static async Task <EquipmentCatalog> FindOrCreateEquipmentCatalogAsync(this CarContext carContext, int databaseId)
        {
            var query         = @"EXECUTE [dbo].[FindOrCreateEquipmentCatalog] 
                          @DatabaseId";
            var parDatabaseId = CarContextExtentions.ParDatabaseIdInput(databaseId);

            return(carContext.EquipmentCatalog.FromSqlRaw(query, parDatabaseId).AsEnumerable().First());
        }
Esempio n. 4
0
        public static async Task <DescriptionCatalog> FindOrCreateDescriptionCatalogAsync(this CarContext carContext, string name)
        {
            var query = @"EXECUTE [dbo].[FindOrCreateDescriptionCatalog] 
                          @Name";

            var parName = CarContextExtentions.ParNameInput(name);

            return(carContext.DescriptionCatalog.FromSqlRaw(query, parName).AsEnumerable().First());
        }
Esempio n. 5
0
        private static DataTable CreateMakesTable(params string[] names)
        {
            var dt = CarContextExtentions.CreateDataTable("Name");

            foreach (var name in names)
            {
                dt.Rows.Add(name);
            }
            return(dt);
        }
Esempio n. 6
0
        public static async Task ActivateNewSpecificationCatalogAsync(
            this CarContext carContext,
            Guid equipmentCatalogId
            )
        {
            var query   = @"EXECUTE [dbo].[ActivateNewSpecificationCatalog]                           
                          @EquipmentCatalogId";
            var parEqId = CarContextExtentions.CreateParGuid("@EquipmentCatalogId", equipmentCatalogId);

            carContext.Database.ExecuteSqlRaw(query, parEqId);
        }
Esempio n. 7
0
        public static async Task <EquipmentVersionCatalog> FindOrCreateEquipmentVersionCatalogAsync(this CarContext carContext, Guid equipmentCatalogId, Guid versionCatalogId)
        {
            var query = @"EXECUTE [dbo].[FindOrCreateEquipmentVersionCatalog] 
                          @VersionCatalogId,
                          @EquipmentCatalogId";

            var parEqId  = CarContextExtentions.CreateParGuid("@EquipmentCatalogId", equipmentCatalogId);
            var parVerId = CarContextExtentions.CreateParGuid("@VersionCatalogId", versionCatalogId);

            return(carContext.EquipmentVersionCatalog.FromSqlRaw(query, parEqId, parVerId).AsEnumerable().First());
        }
Esempio n. 8
0
        private static DataTable CreateModelsTable(params Tuple <string, string>[] rows)
        {
            var dt = CarContextExtentions.CreateDataTable
                     (
                "MakeName",
                "ModelName"
                     );

            foreach (var row in rows)
            {
                dt.Rows.Add(row.Item1, row.Item2);
            }
            return(dt);
        }
Esempio n. 9
0
        public static async Task <SpecificationCatalog> FindOrCreateSpecificationCatalogAsync(
            this CarContext carContext,
            Guid equipmentCatalogId,
            Guid featureCatalogId
            )
        {
            var query = @"EXECUTE [dbo].[FindOrCreateSpecificationCatalog]                           
                          @EquipmentCatalogId,
                          @FeatureCatalogId";

            var parEqId   = CarContextExtentions.CreateParGuid("@EquipmentCatalogId", equipmentCatalogId);
            var parFeatId = CarContextExtentions.CreateParGuid("@FeatureCatalogId", featureCatalogId);

            return(carContext.SpecificationCatalog.FromSqlRaw(query, parEqId, parFeatId).AsEnumerable().First());
        }
        public static async Task <SpecificationInclusionCatalog> FindOrCreateSpecificationInclusionsCatalogAsync(
            this CarContext carContext,
            Guid inclusionCatalogId,
            Guid specificationCatalogId
            )
        {
            var query = @"EXECUTE [dbo].[FindOrCreateSpecificationInclusionCatalog] 
                          @InclusionCatalogId,
                          @SpecificationCatalogId";

            var parIncId  = CarContextExtentions.CreateParGuid("@InclusionCatalogId", inclusionCatalogId);
            var parSpecId = CarContextExtentions.CreateParGuid("@SpecificationCatalogId", specificationCatalogId);

            return(carContext.SpecificationInclusionCatalog.FromSqlRaw(query, parIncId, parSpecId).AsEnumerable().First());
        }
        public static async Task <PricelistCatalog> FindOrCreatePricelistCatalogAsync
        (
            this CarContext carContext,
            string colorName,
            bool?metallic,
            string hue,
            string picture,
            string price,
            DateTime?productionFromDate,
            DateTime?validFromDate,
            Guid equipmentCatalogId
        )
        {
            var query = @"EXECUTE [dbo].[FindOrCreatePricelistCatalog] 
                        @ColorName,  
				        @Metallic,
				        @Hue,
                        @Picture,
				        @Price,
				        @ProductionFromDate,
				        @ValidFromDate,
                        @EquipmentCatalogId";

            var parColorName          = CarContextExtentions.CreateParNVarchar("@ColorName", colorName, 250);
            var parMet                = CarContextExtentions.CreateParBit("@Metallic", metallic);
            var parHue                = CarContextExtentions.CreateParNVarchar("@Hue", hue, 250);
            var parPicture            = CarContextExtentions.CreateParNVarchar("@Picture", picture, 250);
            var parPrice              = CarContextExtentions.CreateParNVarchar("@Price", price, 20);
            var parProductFromDate    = CarContextExtentions.CreateParDateTime2("@ProductionFromDate", productionFromDate);
            var parValidFromDate      = CarContextExtentions.CreateParDateTime2("@ValidFromDate", validFromDate);
            var parEquipmentCatalogId = CarContextExtentions.CreateParGuid("@EquipmentCatalogId", equipmentCatalogId);

            return(carContext.PricelistCatalog.FromSqlRaw
                   (
                       query,
                       parColorName,
                       parMet,
                       parHue,
                       parPrice,
                       parProductFromDate,
                       parValidFromDate,
                       parPicture,
                       parEquipmentCatalogId
                   ).AsEnumerable().FirstOrDefault());
        }
        public static async Task <ModificationCatalog> FindOrCreateModificationCatalogAsync
        (
            this CarContext carContext,
            string makeName,
            string modelName,
            string StartProductionYear)
        {
            var query                  = @"EXECUTE [dbo].[FindOrCreateModificationCatalog] 
                           @MakeName
                          ,@ModelName
                          ,@StartProductionYearT";
            var parMakeName            = CarContextExtentions.CreateParNVarchar("@MakeName", makeName, 255);
            var parModelName           = CarContextExtentions.CreateParNVarchar("@ModelName", modelName, 255);
            var parStartProductionYear = CarContextExtentions.CreateParNVarchar("@StartProductionYear", StartProductionYear, 10);


            return(carContext.ModificationCatalog.FromSqlRaw(query, parMakeName, parModelName, parStartProductionYear).AsEnumerable().First());
        }
        public static async Task <InclusionCatalog> FindOrCreateInclusionCatalogAsync(
            this CarContext carContext,
            bool?standart,
            string description)
        {
            var query = @"EXECUTE [dbo].[FindOrCreateInclusionCatalog] 
                          @Standart,
                          @Description";

            var parStandart = CarContextExtentions.CreateParBit("@Standart", standart);
            var parDesc     = CarContextExtentions.CreateParNVarchar("@Description", description, 255);

            return(carContext.InclusionCatalog.FromSqlRaw(
                       query,
                       parStandart,
                       parDesc
                       ).AsEnumerable().First());
        }
Esempio n. 14
0
        public static Models.MakeCatalog FindOrCreateMakeCatalogAsync(this CarContext carContext, string name)
        {
            var query   = @"EXECUTE [dbo].[FindOrCreateMakeCatalog] 
                          @Name
                          ,@Id OUTPUT";
            var parName = CarContextExtentions.ParNameInput(name);
            var parId   = CarContextExtentions.ParIdOutput();

            carContext.Database.ExecuteSqlRaw(
                query,
                parName,
                parId);

            var mark = new Models.MakeCatalog
            {
                Id   = (Guid)parId.Value,
                Name = name
            };

            return(mark);
        }
        public static async Task <VersionCatalog> FindOrCreateVersionCatalog
        (
            this CarContext carContext,
            string makeName,
            string modelName,
            string versionName,
            string startProductionYear,
            string picture
        )
        {
            var query = @"EXECUTE [dbo].[FindOrCreateVersionCatalog] 
                               @MakeName
                              ,@ModelName
                              ,@VersionName
                              ,@StartProductionYear
                              ,@Picture";

            var makeNamePar =
                CarContextExtentions.CreateParNVarchar
                    ("@MakeName", makeName, 250);

            var modelNamePar =
                CarContextExtentions.CreateParNVarchar
                    ("@ModelName", modelName, 250);

            var versionNamePar =
                CarContextExtentions.CreateParNVarchar
                    ("@VersionName", versionName, 250);

            var startProductionYearPar =
                CarContextExtentions.CreateParNVarchar
                    ("@StartProductionYear", startProductionYear, 4);

            var picturePar =
                CarContextExtentions.CreateParNVarchar
                    ("@Picture", picture, 250);

            return(carContext.VersionCatalog.FromSqlRaw(query, makeNamePar, modelNamePar, versionNamePar, startProductionYearPar, picturePar).AsEnumerable().First());
        }
Esempio n. 16
0
 public static Microsoft.Data.SqlClient.SqlParameter ParDatabaseIdInput(int databaseId)
 {
     return(CarContextExtentions.CreateParInt("@DatabaseId", databaseId));
 }