public void RemoveFromProductCSVById(int id)
        {
            List <prod.Product> productsoverwrite = new List <prod.Product>();

            productsoverwrite = this.ListOfProductCSV();

            prod.Product deleteProduct = productsoverwrite.Single(x => x.Id == id);

            productsoverwrite.Remove(deleteProduct);

            var config = new CsvConfiguration(CultureInfo.InvariantCulture)
            {
                TrimOptions   = TrimOptions.Trim,
                Comment       = '@',
                AllowComments = true,
            };

            using (var writer = new StreamWriter(InputFilePath))
                using (CsvWriter csvWriter = new CsvWriter(writer, config))
                {
                    csvWriter.Context.RegisterClassMap <ProductMap>();


                    csvWriter.WriteRecords(productsoverwrite);
                }
        }
        public void AddToProductCSV(prod.Product product)
        {
            bool append = true;
            //prod.Product productt = new prod.Product {
            //    Id = 123,
            //     Name = "Grapes",
            //     Manufacturer ="Rexer",
            //     ShortCode = "GRAP10",
            //     Description="Fruits",
            //     SellingPrice=350,
            //     ProductCategory ="Food"

            //};
            var config = new CsvConfiguration(CultureInfo.InvariantCulture)
            {
                TrimOptions     = TrimOptions.Trim,
                Comment         = '@',
                AllowComments   = true,
                HasHeaderRecord = !append
            };

            using (var writer = new StreamWriter(InputFilePath, append))
                using (CsvWriter csvWriter = new CsvWriter(writer, config)) {
                    csvWriter.NextRecord();
                    csvWriter.WriteRecord(product);
                }
        }