Exemplo n.º 1
0
        public IHttpActionResult Edit(NoteEx note)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var data = service.Update(note);

                    //if (data == false)
                    //{
                    //    throw new System.Exception("Note not Found in Database according to ID");
                    //}
                    return Ok(data);
                }
                else
                {
                    throw new Exception("Update operation failed");
                }
            }
            catch (Exception exp)//DbUpdateConcurrencyException
            {
                ExceptionLogging.SendExcepToDB(exp);
                return BadRequest(exp.Message);
            }
        }
Exemplo n.º 2
0
        public NoteEx Update(NoteEx note)
        {
            try
            {
                Note _Note = db.Notes.Find(note.Note_Id);
                _Note.Note_Name = note.Note_Name;
                _Note.Note_ProductId = note.Note_ProductId;
                _Note.Note_PageId = note.Note_PageId;
                _Note.Note_Content = note.Note_Content;
                _Note.Note_ModifiedDate = DateTime.Now;

                db.Entry(_Note).State = EntityState.Modified;
                db.SaveChanges();

                return Transform(_Note);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
Exemplo n.º 3
0
        public NoteEx Add(NoteEx item)
        {
            try
            {
                Note _Note = new Note();
                _Note.Note_Name = item.Note_Name;
                _Note.Note_PageId = item.Note_PageId;
                _Note.Note_ProductId = item.Note_ProductId;
                _Note.Note_Content = item.Note_Content;
                _Note.Note_CreatedDate = DateTime.Now;
                _Note.Note_ModifiedDate = DateTime.Now;

                db.Notes.Add(_Note);
                db.SaveChanges();
                return item;
            }
            catch(Exception exp)
            {
                throw exp;
            }
        }
Exemplo n.º 4
0
 private Note Transform(NoteEx note)
 {
     var _note = new Note
     {
         Note_Content = note.Note_Content,
         Note_CreatedDate = note.Note_CreatedDate,
         Note_Id = note.Note_Id,
         Note_ModifiedDate = DateTime.Now,
         Note_Name = note.Note_Name,
         Note_PageId = note.Note_PageId,
         Note_ProductId = note.Note_ProductId
     };
     return _note;
 }
Exemplo n.º 5
0
 public NoteEx Update(NoteEx note)
 {
     return repo.Update(note);
 }
Exemplo n.º 6
0
 public NoteEx Add(NoteEx note)
 {
     return repo.Add(note);
 }