public ValueTask <bool> UpdateNote( int id, NoteInput input, Author editor, CancellationToken cancellationToken = default) { var exists = _notes.TryGetValue(id, out var oldNote); if (!exists) { return(new ValueTask <bool>(false)); } var mustAddContributor = oldNote.Creator != editor && !oldNote.Contributors.Contains(editor); var updatedNote = new Note( oldNote.Id, input.Title ?? oldNote.Title, input.Content ?? oldNote.Content, oldNote.Creator, oldNote.DateCreated, mustAddContributor ? oldNote.Contributors.Append(editor).ToList() : oldNote.Contributors.ToList(), oldNote.Keywords.ToList()); _notes.Remove(id); _notes.Add(id, updatedNote); return(new ValueTask <bool>(true)); }
private void Main_BandedGridView_RowCellClick(object sender, RowCellClickEventArgs e) { GridView view = sender as GridView; if (e.Column.FieldName == "NoteStatusColor") { var selected = view.GetFocusedRow().CastTo <GetCanDoiSoPhatSinhTaiKhoan>(); NoteInput frm = new NoteInput { NoteInfoData = new NoteInfo { NoteID = selected.NoteID, NumAttribute = FromDate.Year, CharAttribute = selected.AccountID } }; if (frm.ShowDialog() == DialogResult.OK) { selected.NoteID = frm.NoteInfoData.NoteID; selected.NoteStatus = frm.NoteInfoData.NoteStatus; } } }
/// <summary> /// Initialize variables. /// </summary> private void Awake() { // Initialize the sample rate setting from unity in variable. sampleRate = (float)AudioSettings.outputSampleRate; // Get the 'NoteInput'-Script. noteInputScript = GetComponent <NoteInput>(); }
public async Task <Note> Add(NoteInput note) { var entity = mapper.MapNote(note, new NoteEntity()); this.dbContext.Add(entity); await SaveChanges(); return(mapper.MapNote(entity, new Note())); }
public Note UpdateNote(long id, NoteInput noteUpdate) { var note = GetNote(id); note.Title = noteUpdate.Title; note.Description = noteUpdate.Description; _context.Notes.Update(note); _context.SaveChanges(); return(note); }
void Awake() { Metronome.instance.SignalBeat += OnBeat; Metronome.instance.SignalMeasure += OnMeasure; Metronome.instance.SignalPhrase += OnPhrase; Metronome.instance.SignalSixteenth += OnSixteenth; _sampler = GetComponent <Sampler> (); // _measure = new int[] // { // 12, 10, 8, 7, // I // 0, 3, 7, 10, // I // 12, 7, 10, 11, // I // 12, 14, 15, 16, // I // // 17, 9, 10, 11, // IV // 12, 10, 3, 2, // IV // 0, 2, 3, 4, // I // 5, 6, 7, 6, // I // // 7, 5, 7, 3, // V // 5, 3, 10, 11, // IV // 12, 0, 3, 1, // I // 2, 8, 7, 11 // ii V // }; RhythmicPhrase phrase = new RhythmicPhrase(4, 4); for (int i = 0; i < 16; i++) { if (Random.value < 0.5f) { phrase.WriteNote(i / 4, i % 4, 1); } else { phrase.WriteRest(i / 4, i % 4, 1); } } NoteInput[] noteInputPhrase = phrase.GetPhrase(); _measure = new int[noteInputPhrase.Length]; for (int i = 0; i < noteInputPhrase.Length; i++) { NoteInput input = noteInputPhrase [i]; if (input == NoteInput.Start) { _measure [i] = 0; } else if (input == NoteInput.Rest) { _measure [i] = -100000; } } }
public ActionResult <Note> Update([FromBody] NoteInput note, long id) { try { return(Ok(_service.UpdateNote(id, note))); } catch (System.Exception ex) { return(BadRequest(ex.Message)); } }
public IActionResult Post([FromBody] NoteInput input) { input.Id = Guid.NewGuid().ToString().TrimStart('{').TrimEnd('}'); if (Validator.TryValidate(input, out Note model, out string errorMessage)) { var createdModel = _DataProvider.Post(model); if (createdModel != null) { return(Json(createdModel)); } }
public Note AddNote(NoteInput noteInput) { var note = new Note { Title = noteInput.Title, Description = noteInput.Description }; _context.Notes.Add(note); _context.SaveChanges(); return(note); }
public async Task <Note> Update(Guid noteId, NoteInput note) { var entity = await this.Entity(noteId); if (entity != null) { mapper.MapNote(note, entity); await SaveChanges(); return(mapper.MapNote(entity, new Note())); } throw new KeyNotFoundException($"Cannot find note {noteId.ToString()}"); }
void Write(NoteInput noteInput, int beatStart, int beatDivisionStart, int lengthInDivisions) { if (beatStart >= _beats) { Debug.LogError("invalid beat start: " + beatStart); } if (beatDivisionStart >= _divisionsPerBeat) { Debug.LogError("invalid beat divisionStart: " + beatDivisionStart); } if (lengthInDivisions < 1) { Debug.LogError("invalid length: " + lengthInDivisions); } if (noteInput == NoteInput.End) { Debug.LogError("can't write end of note on its own"); } if (noteInput == NoteInput.Hold) { Debug.LogError("can't write held note on its own"); } int start = beatStart + beatDivisionStart; int end = start + lengthInDivisions; if (end >= _phrase.Count) { Debug.LogError("length extends past end of phrase. start: " + start + ", end: " + end + ", length: " + lengthInDivisions + ", totalDivisions: " + _totalDivisions); } if (noteInput == NoteInput.Start) { _phrase[start] = NoteInput.Start; for (int i = start + 1; i < end - 1; i++) { _phrase[i] = NoteInput.Hold; } _phrase[end] = NoteInput.End; } else if (noteInput == NoteInput.Rest) { for (int i = start; i < end; i++) { _phrase[i] = NoteInput.Rest; } } }
private void Awake() { input = GetComponent <NoteInput>(); voicesPool = new Voice[polyphony]; activeVoices = new List <Voice>(); freeVoices = new Stack <Voice>(); noteDict = new Dictionary <int, Voice>(); for (int i = 0; i < voicesPool.Length; i++) { voicesPool[i] = new Voice(waveType, gain); freeVoices.Push(voicesPool[i]); } }
public async Task <ServiceResult <NoteModel> > Add(NoteInput input) { authService.AssertAuthentication(); var tags = new List <Tag>(); var note = mapper.Map <Note>(input); note.Title = whitespace.Replace(note.Title.Trim(), " "); if (note.Title.Length < 10) { return(BadRequest <NoteModel>()); // format this somehow to convention } if (note.ParentId != null) { var parent = await dbContext.Notes.FindAsync(note.ParentId); if (parent == null) { return(BadRequest <NoteModel>()); } if (parent.AuthorId != authService.GetUserId()) { return(Unauthorized <NoteModel>()); } note.RootId = parent.IsRoot ? note.ParentId : parent.RootId; tags.AddRange(parent.Tags); // parents tags can be excluded here } else { note.IsRoot = true; } tags.AddRange(await ConvertTags(note.Tags)); note.Tags = tags; note.AuthorId = authService.GetUserId(); await dbContext.Notes.AddAsync(note); await dbContext.SaveChangesAsync(); note.Url = whitespace.Replace(note.Title, "-").ToLowerInvariant() + "-" + note.Id; await dbContext.SaveChangesAsync(); return(await Get(note.Id)); }
public ValueTask <Note> AddNote( NoteInput input, Author creator, CancellationToken cancellationToken = default) { var newNote = new Note( _idCounter++, input.Title, input.Content, creator, DateTime.UtcNow, new List <Author>(), new List <Keyword>()); _notes.Add(newNote.Id, newNote); return(new ValueTask <Note>(newNote)); }
public async Task <ServiceResult <NoteModel> > Update(int id, NoteInput input) { var note = await dbContext.Notes.Where(n => n.Id == id).FirstOrDefaultAsync(); if (note == null) { return(NotFound <NoteModel>()); } if (note.AuthorId != authService.GetUserId()) { return(Unauthorized <NoteModel>()); // check if ? fails condition or makes null == UserId (wrong) } note.Title = input.Title; note.Content.Text = input.Text; note.Description = input.Description; await dbContext.SaveChangesAsync(); return(await Get(id)); }
public async Task <Note> Update(Guid noteId, [FromBody] NoteInput note) { return(await repo.Update(noteId, note)); }
public NoteEntity MapNote(NoteInput src, NoteEntity dest) { return(mapper.Map(src, dest)); }
public async Task <Note> Add([FromBody] NoteInput note) { return(await repo.Add(note)); }
public async Task <ActionResult <NoteModel> > Update(int id, NoteInput input) => await noteService.Update(id, input).MapToAction();
public async Task <ActionResult <NoteModel> > Add(NoteInput input) => await noteService.Add(input).MapToAction();
public async Task <ServiceResult <NoteModel> > Update(int id, NoteInput input) => await httpClient.PutAsJsonAsync($"api/note/{id}", input);
public async Task <ServiceResult <NoteModel> > Add(NoteInput note) => await httpClient.PostAsJsonAsync("api/note", note);
public ActionResult <Note> AddNote([FromBody] NoteInput newNote) { return(_service.AddNote(newNote)); }