Пример #1
0
        // Get Values by Record ID
        public EVA_Record ListValuesByRecordID(int ID)
        {
            EVA_Record p = null;


            DataProvider.ExecuteCmd(GetConnection, "dbo.EVA_Values_Select_By_RecordID"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@ID", ID);
            }, map : delegate(IDataReader reader, short set)
            {
                if (set == 0)
                {
                    p = new EVA_Record();
                    int startingIndex = 0;    //startingOrdinal


                    p.ID        = reader.GetSafeInt32(startingIndex++);
                    p.EntityID  = reader.GetSafeInt32(startingIndex++);
                    p.WebsiteId = reader.GetSafeInt32(startingIndex++);
                    p.Value     = new List <Value>();
                }
                else if (set == 1)
                {
                    Value x           = new Value();
                    int startingIndex = 0;    //startingOrdinal

                    x.RecordID      = reader.GetSafeInt32(startingIndex++);
                    x.AttributeID   = reader.GetSafeInt32(startingIndex++);
                    x.ValueString   = reader.GetSafeString(startingIndex++);
                    x.ValueInt      = reader.GetSafeInt32(startingIndex++);
                    x.ValueDecimal  = reader.GetSafeDecimal(startingIndex++);
                    x.ValueText     = reader.GetSafeString(startingIndex++);
                    x.ValueGeo      = reader.GetSafeDecimal(startingIndex++);
                    x.AttributeSlug = reader.GetSafeString(startingIndex++);
                    x.AttributeName = reader.GetSafeString(startingIndex++);
                    p.Value.Add(x);
                }
            }
                                    );

            return(p);
        }
        // list dealer records
        public List <EVA_Record> ListVehicleRecordByDealerID(int DealerID, PaginateListRequestModel model)//for other one only id as param
        {
            List <EVA_Record> myList = null;


            DataProvider.ExecuteCmd(GetConnection, "dbo.EVA_Records_Select_By_DealerID"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@DealerID", DealerID);
                paramCollection.AddWithValue("@CurrentPage", model.CurrentPage);
                paramCollection.AddWithValue("@ItemsPerPage", model.ItemsPerPage);
            }, map : delegate(IDataReader reader, short set)
            {
                if (set == 0)
                {
                    EVA_Record p      = new EVA_Record();
                    int startingIndex = 0;    //startingOrdinal
                    p.ID        = reader.GetSafeInt32(startingIndex++);
                    p.EntityID  = reader.GetSafeInt32(startingIndex++);
                    p.WebsiteId = reader.GetSafeInt32(startingIndex++);
                    p.Value     = new List <Value>();
                    p.Pictures  = new List <Domain.Media>();  //this line only give a empty [];


                    if (myList == null)
                    {
                        myList = new List <EVA_Record>();
                    }

                    myList.Add(p);
                }
                else if (set == 1)
                {
                    Value x           = new Value();
                    int startingIndex = 0;    //startingOrdinal

                    x.RecordID      = reader.GetSafeInt32(startingIndex++);
                    x.AttributeID   = reader.GetSafeInt32(startingIndex++);
                    x.ValueString   = reader.GetSafeString(startingIndex++);
                    x.ValueInt      = reader.GetSafeInt32(startingIndex++);
                    x.ValueDecimal  = reader.GetSafeDecimal(startingIndex++);
                    x.ValueText     = reader.GetSafeString(startingIndex++);
                    x.ValueGeo      = reader.GetSafeDecimal(startingIndex++);
                    x.AttributeSlug = reader.GetSafeString(startingIndex++);
                    x.AttributeName = reader.GetSafeString(startingIndex++);

                    //insert loop here
                    for (int i = 0; i < myList.Count; i++)
                    {
                        if (myList[i].ID == x.RecordID)
                        {
                            myList[i].Value.Add(x);
                            break;
                        }
                    }

                    // within the loop  p.Value.Add(x);
                }
                else if (set == 2)
                {
                    Domain.Media w    = new Domain.Media();
                    int startingIndex = 0;    //startingOrdinal
                    w.ID            = reader.GetSafeInt32(startingIndex++);
                    w.MediaType     = reader.GetSafeString(startingIndex++);
                    w.Path          = reader.GetSafeString(startingIndex++);
                    w.FileName      = reader.GetSafeString(startingIndex++);
                    w.FileType      = reader.GetSafeString(startingIndex++);
                    w.Title         = reader.GetSafeString(startingIndex++);
                    w.Description   = reader.GetSafeString(startingIndex++);
                    w.UserID        = reader.GetSafeString(startingIndex++);
                    w.ThumbnailPath = reader.GetSafeString(startingIndex++);
                    w.CreatedDate   = reader.GetSafeDateTime(startingIndex++);
                    w.ModifiedDate  = reader.GetSafeDateTime(startingIndex++);
                    w.MediaId       = reader.GetSafeInt32(startingIndex++);
                    w.RecordId      = reader.GetSafeInt32(startingIndex++);
                    w.DealerId      = reader.GetSafeInt32(startingIndex++);
                    w.IsCoverPhoto  = reader.GetSafeBool(startingIndex++);
                    //insert loop here
                    for (int y = 0; y < myList.Count; y++)
                    {
                        if (myList[y].ID == w.RecordId)
                        {
                            myList[y].Pictures.Add(w);
                            break;
                        }
                    }
                }
            }
                                    );

            return(myList);
        }
Пример #3
0
        // Function to List all Records with a common Value
        public List <EVA_Record> RecordsSearchByValue(int EntityId, RecordByValueRequestModel model)
        {
            List <EVA_Record> myList = null;



            DataProvider.ExecuteCmd(GetConnection, "dbo.EVA_Records_Search_By_Value"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@EntityID", EntityId);
                paramCollection.AddWithValue("@AttributeID", model.AttributeId);
                paramCollection.AddWithValue("@ValueString", model.ValueString);
                paramCollection.AddWithValue("@CurrentPage", model.CurrentPage);
                paramCollection.AddWithValue("@ItemsPerPage", model.ItemsPerPage);
            }, map : delegate(IDataReader reader, short set)
            {
                if (set == 0)
                {
                    EVA_Record p      = new EVA_Record();
                    int startingIndex = 0;    //startingOrdinal


                    p.ID        = reader.GetSafeInt32(startingIndex++);
                    p.EntityID  = reader.GetSafeInt32(startingIndex++);
                    p.WebsiteId = reader.GetSafeInt32(startingIndex++);
                    p.Value     = new List <Value>();

                    if (myList == null)
                    {
                        myList = new List <EVA_Record>();
                    }

                    myList.Add(p);
                }
                else if (set == 1)
                {
                    Value x           = new Value();
                    int startingIndex = 0;    //startingOrdinal

                    x.RecordID     = reader.GetSafeInt32(startingIndex++);
                    x.AttributeID  = reader.GetSafeInt32(startingIndex++);
                    x.ValueString  = reader.GetSafeString(startingIndex++);
                    x.ValueInt     = reader.GetSafeInt32(startingIndex++);
                    x.ValueDecimal = reader.GetSafeDecimal(startingIndex++);
                    x.ValueText    = reader.GetSafeString(startingIndex++);
                    x.ValueGeo     = reader.GetSafeDecimal(startingIndex++);

                    //insert loop here
                    for (int i = 0; i < myList.Count; i++)
                    {
                        if (myList[i].ID == x.RecordID)
                        {
                            myList[i].Value.Add(x);
                            break;
                        }
                    }

                    // within the loop  p.Value.Add(x);
                }
            }
                                    );

            return(myList);
        }