// create
        public int Insert(ValueRequestModel model, int recordID)
        {
            int uid = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "EVA_Value_Insert"
                                         , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@RecordID", recordID);
                paramCollection.AddWithValue("@AttributeID", model.AttributeId);
                paramCollection.AddWithValue("@ValueString", model.ValueString);
                paramCollection.AddWithValue("@ValueInt", model.ValueInt);
                paramCollection.AddWithValue("@ValueDecimal", model.ValueDecimal);
                paramCollection.AddWithValue("@ValueText", model.ValueText);
                paramCollection.AddWithValue("@ValueGeo", model.ValueGeo);

                SqlParameter p = new SqlParameter("@OID", System.Data.SqlDbType.Int);
                p.Direction    = System.Data.ParameterDirection.Output;

                paramCollection.Add(p);
            }, returnParameters : delegate(SqlParameterCollection param)
            {
                int.TryParse(param["@OID"].Value.ToString(), out uid);
            }
                                         );
            return(uid);
        }
 // update
 public void Update(ValueRequestModel model, int recordID)
 {
     DataProvider.ExecuteNonQuery(GetConnection, "dbo.EVA_Value_Update"
                                  , inputParamMapper : delegate(SqlParameterCollection paramCollection)
     {
         paramCollection.AddWithValue("@RecordID", recordID);
         paramCollection.AddWithValue("@AttributeID", model.AttributeId);
         paramCollection.AddWithValue("@ValueString", model.ValueString);
         paramCollection.AddWithValue("@ValueInt", model.ValueInt);
         paramCollection.AddWithValue("@ValueDecimal", model.ValueDecimal);
         paramCollection.AddWithValue("@ValueText", model.ValueText);
         paramCollection.AddWithValue("@ValueGeo", model.ValueGeo);
     }, returnParameters : delegate(SqlParameterCollection param)
     {
     }
                                  );
 }
Esempio n. 3
0
        public async Task <IHttpActionResult> CreateValue([FromBody] ValueRequestModel model)
        {
            var value = new ValueReference()
            {
                Id      = model.Id,
                Name    = model.Name,
                Value   = model.Value,
                IsValid = model.IsValid,
                AddedOn = model.AddedOn
            };
            var response = new ValueResponseModel()
            {
                Value = value
            };

            return(this.Ok(response));
        }
        public Task <int> parseCSV(AdminImportRequestModel model)
        {
            return(Task.Run(() =>
            {
                //Use downloadDate because when the file gets downloaded it is saved by date and then this function runs
                //Directly after the file has been downloaded
                String downloadDate = DateTime.Now.ToString("dd.MM.yyyy");
                string destination = AppDomain.CurrentDomain.BaseDirectory + "dtc/" + downloadDate + "/dtcinventory.txt";
                _AdminImport = model;

                EVA_Entity Entity = _entityService.GetByID(model.EntityId);

                using (var sr = new StreamReader(destination))
                {
                    var csv = new CsvReader(sr);
                    csv.Configuration.Delimiter = "\t";
                    csv.Configuration.IgnoreHeaderWhiteSpace = true;
                    var records = csv.GetRecords <TestDTCDealerRequestModel>();


                    foreach (var record in records)
                    {
                        if (record == null)
                        {
                            break;
                        }
                        //Im making a new instance of RRM which is going to get passed in at the end
                        RecordRequestModel RRM = new RecordRequestModel();
                        RRM.EntityId = this._AdminImport.EntityId;
                        RRM.WebsiteId = this._AdminImport.WebsiteId;
                        RRM.AttributeId = 136;
                        RRM.Values = new List <ValueRequestModel>();
                        RRM.Medias = new List <MediaRequestModel>();

                        TestDTCDealerRequestModel VehicleRM = new TestDTCDealerRequestModel();

                        PropertyInfo[] Y = VehicleRM.GetType().GetProperties();

                        for (var p = 0; p < Y.Length; p++)
                        {
                            string slug = UtilityService.camelCaseToDash(Y[p].Name);

                            foreach (var attribute in Entity.Attributes)
                            {
                                if (slug == attribute.Slug)
                                {
                                    ValueRequestModel ValueRm = new ValueRequestModel();
                                    ValueRm.AttributeId = attribute.ID;
                                    ValueRm.ValueString = record.GetType().GetProperty(Y[p].Name).GetValue(record, null).ToString();
                                    System.Diagnostics.Debug.WriteLine(ValueRm.ValueString);
                                    RRM.Values.Add(ValueRm);
                                }
                            }
                        }

                        //Within the CSV there are numbers seperated by pipes which are the img number
                        //Here we seperate them on the pipe and insert them into the url
                        if (record.Images != null)
                        {
                            string[] RecordMediaArray = record.Images.Split('|');
                            var x = 0;
                            foreach (string recordMediaPath in RecordMediaArray)
                            {
                                RecordMediaRequestModel RecordMedia = new RecordMediaRequestModel();
                                RecordMedia.FileName = "http://img.leaddelivery.net/images/" + record.VIN + "/Original/" + recordMediaPath + ".jpg";
                                RecordMedia.MediaType = "3";
                                RecordMedia.FileType = "image/jpeg";
                                System.Diagnostics.Debug.WriteLine(RecordMedia.FileName);
                                //Setting first image equal to the cover photo
                                if (x == 0)
                                {
                                    RecordMedia.IsCoverPhoto = true;
                                }
                                else
                                {
                                    RecordMedia.IsCoverPhoto = false;
                                }

                                RRM.Medias.Add(RecordMedia);

                                x++;
                            }
                        }
                        //The RRM final gets inserted into the ProcessAsync Task
                        _InsertRecord.ProcessAsync(RRM);
                    }
                }
                return 5;
            }));
        }