private void OnEnable() { poolableDB = (PoolDatabase)target; string interactablesDBPath = "Assets/Data/Database/InteractablesDatabase.asset"; interactablesDB = AssetDatabase.LoadAssetAtPath <InteractablesDatabase>(interactablesDBPath); tileType = interactablesDB[0]; }
public async Task <IActionResult> GetValues(int id) { var values = _context.Values.Find(id); PoolDatabase Poll = new PoolDatabase() { Id = values.poll_id, Description = values.poll_description, }; var options = JArray.Parse (JsonConvert.SerializeObject (_context.Options. Where(o => o.poll_id == id).Select(o => new { o.option_id, o.option_description }). ToArray())); return(Ok(new { poll_id = values.poll_id, poll_description = values.poll_description, options = options })); }
public async Task <IActionResult> Post(PoolDatabase context, int id) { var pollModel = new PoolDatabase() { poll_description = context.Description }; using (var PollDBContext = _context.Database.BeginTransaction()) { try { _context.Values.Add(pollModel); _context.SaveChanges(); context.poll_id = pollModel.poll_id; ICollection <Option> options = new HashSet <Option>(); _context.Options.ToList().ForEach( description => options.Add( new Option() { option_description = description.ToString(), poll_id = context.Id }) ); _context.Options.AddRange(options); _context.SaveChanges(); PollDBContext.Commit(); } catch (Exception ex) { PollDBContext.Rollback(); } } return(Ok(new { poll_id = context.Id })); }