public ActionResult SavedMachines()
 {
     using (drummachineEntities db = new drummachineEntities())
     {
         var result = db.machines.Select(x => new { x.id, x.name }).ToList();
         return(Json(result));
     }
 }
        public ActionResult SaveGrid(int machineID, string data)
        {
            List <instrument> insturmentsToSave = JsonConvert.DeserializeObject <List <instrument> >(data);

            using (drummachineEntities db = new drummachineEntities())
            {
                foreach (var item in insturmentsToSave)
                {
                    item.machineID = machineID;

                    db.AddOrAttach <sound>(item.sound);
                    db.AddOrAttach <instrument>(item);
                }

                db.SaveChanges();

                return(Content(JsonConvert.SerializeObject(insturmentsToSave, new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                }), "application/json"));
            }
        }