public QuickNoteModel GetQuickNoteById(int id) { QuickNoteModel model = null; var entity = _uow.QuickNotes.GetById(id); if (entity != null) { model = MappingUtil.Map <QuickNote, QuickNoteModel>(entity); } return(model); }
public bool UpdateQuickNote(QuickNoteModel model) { try { var entity = MappingUtil.Map <QuickNoteModel, QuickNote>(model); _uow.QuickNotes.Update(entity); _uow.SaveChanges(); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } return(true); }
public HttpResponseMessage Patch([FromBody] QuickNoteModel model) { try { if (ModelState.IsValid == false || _quickNoteSvc.UpdateQuickNote(model) == false) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } return(Request.CreateResponse(HttpStatusCode.OK, model)); } catch (ServiceException ex) { return(Request.CreateResponse(ex.HttpStatusCode, ex.Message)); } }
public void UpdateModel(QuickNoteModel model) { //var hasChanges = false; //if(model.Notes != null && model.Notes.Length != 0) //{ // model.TextContent = model.Notes; // var entity = _uow.QuickNotes.GetById(model.Id); // entity.TextContent = entity.Notes; // entity.Notes = ""; // _uow.QuickNotes.Update(entity); // hasChanges = true; //} //if (hasChanges) // _uow.SaveChanges(); }