Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
        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)
            });
        }
Exemplo n.º 4
0
        public CodeNote Get(int noteid)
        {
            var retVal = new CodeNote();

            try
            {
                retVal = repo.GetNotes().FirstOrDefault(x => x.CodeNoteId == noteid);
                return(retVal);
            }
            catch (Exception)
            {
                return(retVal);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
 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);
 }