Beispiel #1
0
        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>();
    }
Beispiel #4
0
        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()));
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
    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;
            }
        }
    }
Beispiel #7
0
 public ActionResult <Note> Update([FromBody] NoteInput note, long id)
 {
     try
     {
         return(Ok(_service.UpdateNote(id, note)));
     }
     catch (System.Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Beispiel #8
0
 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));
         }
     }
Beispiel #9
0
        public Note AddNote(NoteInput noteInput)
        {
            var note = new Note
            {
                Title       = noteInput.Title,
                Description = noteInput.Description
            };

            _context.Notes.Add(note);
            _context.SaveChanges();
            return(note);
        }
Beispiel #10
0
        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;
            }
        }
    }
Beispiel #12
0
    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]);
        }
    }
Beispiel #13
0
        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));
        }
Beispiel #14
0
        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));
        }
Beispiel #15
0
        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));
        }
Beispiel #16
0
 public async Task <Note> Update(Guid noteId, [FromBody] NoteInput note)
 {
     return(await repo.Update(noteId, note));
 }
Beispiel #17
0
 public NoteEntity MapNote(NoteInput src, NoteEntity dest)
 {
     return(mapper.Map(src, dest));
 }
Beispiel #18
0
 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();
Beispiel #21
0
 public async Task <ServiceResult <NoteModel> > Update(int id, NoteInput input)
 => await httpClient.PutAsJsonAsync($"api/note/{id}", input);
Beispiel #22
0
 public async Task <ServiceResult <NoteModel> > Add(NoteInput note) => await httpClient.PostAsJsonAsync("api/note", note);
Beispiel #23
0
 public ActionResult <Note> AddNote([FromBody] NoteInput newNote)
 {
     return(_service.AddNote(newNote));
 }