public void TestGetSizeFromNote(string note, int expectedLength, FieldSize expectedFieldSize) { var n = new CodeNote(1, note); Assert.That(n.FieldSize, Is.EqualTo(expectedFieldSize)); Assert.That(n.Length, Is.EqualTo(expectedLength)); }
public bool UpdateNote(CodeNote note) { try { var rec = dbc.CodeNodes.FirstOrDefault(x => x.CodeNoteId == note.CodeNoteId); if (rec != null) { var record = new CodeNote { CodeNoteId = note.CodeNoteId, Title = note.Title, Description = note.Description ?? string.Empty, Snippet = note.Snippet ?? string.Empty, URL = note.URL ?? string.Empty, StatusCode = note.StatusCode = "A", UpdateDate = note.UpdateDate = DateTime.Now }; dbc.CodeNodes.AddOrUpdate(record); dbc.SaveChanges(); return(true); } return(false); } catch (Exception ex) { _logger.Error(ex, ex.Message); return(false); } }
public CodeNoteResponse Map(CodeNote source) { if (source == null) { return(null); } return(new CodeNoteResponse { Id = source.Id, Title = source.Title, Description = source.Description, ProjectId = source.ProjectId, NoteTypeId = source.NoteTypeId, GeneralSubjectId = source.GeneralSubjectId, SpecificSubjectId = source.SpecificSubjectId, IsBookMarked = source.IsBookMarked, CreatedDate = source.CreatedDate, ModifiedDate = source.ModifiedDate, UserId = source.UserId, GeneralSubjectResponse = _generalSubjectMapper.Map(source.GeneralSubject), NoteTypeResponse = _noteTypeMapper.Map(source.NoteType), ProjectResponse = _projectMapper.Map(source.Project), SpecificSubjectResponse = _specificSubjectMapper.Map(source.SpecificSubject), UserResponse = _userMapper.Map(source.User) }); }
public CodeNote Get(int noteid) { var retVal = new CodeNote(); try { retVal = repo.GetNotes().FirstOrDefault(x => x.CodeNoteId == noteid); return(retVal); } catch (Exception) { return(retVal); } }
public bool Update([FromBody] CodeNote note) { bool retVal = false; try { if (!ModelState.IsValid) { return(false); } if (string.IsNullOrWhiteSpace(note.Title)) { return(retVal); } retVal = repo.UpdateNote(note); return(retVal); } catch (Exception) { return(retVal); } }
public bool AddNote(CodeNote note) { try { var rec = new CodeNote { Title = note.Title, Description = note.Description ?? string.Empty, Snippet = note.Snippet ?? string.Empty, URL = note.URL ?? string.Empty, StatusCode = note.StatusCode = "A", UpdateDate = note.UpdateDate = DateTime.Now }; dbc.CodeNodes.Add(rec); dbc.SaveChanges(); return(true); } catch (Exception ex) { _logger.Error(ex, ex.Message); return(false); } }
public CodeNote Add(CodeNote codeNote) { return(_codeNetContext.CodeNote.Add(codeNote).Entity); }