Exemplo n.º 1
0
        public string InsertManualBuffer(BufferGridViewHolder data)
        {
            using (var dataAccess = new BufferDataAccess())
            {
                var selectedLocation = dataAccess.GetLocationId(data.LocationWwd);
                if (selectedLocation == null)
                {
                    return("Invalid Locaiton Code Entered");
                }
                var carGroupId = dataAccess.GetCarGroupId(selectedLocation.country, data.CarGroup);
                if (carGroupId == 0)
                {
                    return("Invalid Car Group Entered");
                }

                var resBuffer = new ResBuffer
                {
                    LocId    = selectedLocation.dim_Location_id,
                    CarGrpId = carGroupId,
                    Value    = data.Value
                };
                dataAccess.InsertBuffer(resBuffer);
                dataAccess.Submit();
            }
            return("Entry Added");
        }
Exemplo n.º 2
0
        public List <BufferGridViewHolder> GetBufferGridViewHolders(ReportsParameters reportParams)
        {
            List <BufferGridViewHolder> returned;

            using (var dataAccess = new BufferDataAccess())
            {
                returned = dataAccess.GetDataGridAdditions(reportParams);
            }
            return(returned);
        }
Exemplo n.º 3
0
        public void UpdateBuffers(List <BufferGridViewHolder> adData)
        {
            var buffers = adData.Select(d => new ResBuffer
            {
                Id = d.Identifier, CarGrpId = d.CarGroupId, LocId = d.LocationWwdId, Value = d.Value
            }).ToList();

            using (var dataAccess = new BufferDataAccess())
            {
                dataAccess.AttachBuffers(buffers);
                dataAccess.Submit();
            }
        }
Exemplo n.º 4
0
        public void DeleteBuffers(List <BufferGridViewHolder> entitiesToDelete)
        {
            var rb = entitiesToDelete.Select(e => new ResBuffer
            {
                Id = e.Identifier, CarGrpId = e.CarGroupId, LocId = e.LocationWwdId, Value = e.Value
            }).ToList();

            using (var dataAccess = new BufferDataAccess())
            {
                dataAccess.DeleteBuffers(rb);
                dataAccess.Submit();
            }
        }
Exemplo n.º 5
0
        public string InsertNewBuffers(List <ResBuffer> rb, string country)
        {
            using (var dataAccess = new BufferDataAccess())
            {
                try
                {
                    dataAccess.ClearBuffersForCountry(country);
                    dataAccess.InsertBuffers(rb);
                }
                catch (Exception e)
                {
                    return(e.Message);
                }
                dataAccess.Submit();
            }

            return("Buffers Successfully Uploaded");
        }
Exemplo n.º 6
0
        private void ParseRawData(IEnumerable <RawBufferHolder> rawData, BufferFileSummary bfs, string country)
        {
            bfs.Buffers = new List <ResBuffer>();

            using (var dataAccess = new BufferDataAccess())
            {
                foreach (var rd in rawData)
                {
                    var location = dataAccess.GetLocationId(rd.Location);
                    if (location == null || location.country != country)
                    {
                        bfs.RowsSkipped++;
                        continue;
                    }

                    var groupId = dataAccess.GetCarGroupId(location.country, rd.CarGroup);
                    if (groupId == 0)
                    {
                        bfs.RowsSkipped++;
                        continue;
                    }

                    int number;
                    var parseSucceeded = int.TryParse(rd.Number, out number);
                    if (!parseSucceeded)
                    {
                        bfs.RowsSkipped++;
                        continue;
                    }


                    var rAdd = new ResBuffer
                    {
                        LocId    = location.dim_Location_id,
                        CarGrpId = groupId,
                        Value    = number
                    };
                    bfs.Buffers.Add(rAdd);
                    bfs.ValidRows++;
                }
            }
        }