// Using Stream Writer to store inserted data
        public void AddToFile(DuckFeedingRecord recorditem)
        {
            StreamWriter sw = new StreamWriter(String.Concat(path, "/duckFeedingDB.csv"));

            sw.WriteLine(string.Concat("Id", ",", "Time", ",", "Food",
                                       ",", "Location", ",", ",", "Count", "FoodAmount", ",", "FoodType", ",isPeriodic", ",", "Period"));
            int count = _context.DuckFeedingRecords.Count();

            for (int i = 0; i < count; i++)
            {
                var item = _context.DuckFeedingRecords.LastOrDefault();
                //if (i != _context.DuckFeedingItems.Count()-1)
                //{
                //sw.WriteLine(string.Concat(tmp.Id.ToString(), ",", tmp.Time.ToString(), ",", tmp.Food,
                //",", tmp.Location, ",", tmp.Count, ",", tmp.FoodAmount, ",", tmp.FoodType, ",", tmp.Repeat.ToString(), ",", tmp.Period));
                //}
                if (item.Repeat == true)
                {
                    sw.WriteLine(string.Concat(item.Id.ToString(), ",", item.Time.ToString(), ",", item.Food,
                                               ",", item.Location, ",", item.Count, ",", item.FoodAmount, ",", item.FoodType, ",", item.Repeat.ToString(), ",", item.Period));
                }
                else
                {
                    sw.WriteLine(string.Concat(item.Id.ToString(), ",", item.Time.ToString(), ",", item.Food,
                                               ",", item.Location, ",", item.Count, ",", item.FoodAmount, ",", item.FoodType, ",", "false", ",", "0"));
                }

                _context.DuckFeedingRecords.Remove(item);
                _context.SaveChanges();
            }
            sw.Close();
        }
        public IActionResult Create(DuckFeedingRecord item)
        {
            _context.DuckFeedingRecords.Add(item);
            _context.SaveChanges();

            AddToFile(item);

            return(CreatedAtRoute("GetDuckFeedingRecord", new { id = item.Id }, item));
        }