public async Task <HttpResponseMessage> PutNote(Int32 contactId, Int32 noteId, NoteDTO model) { HttpResponseMessage result = null; if (noteId == 0) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } Note dbNote = this._noteService.Get(noteId); if (dbNote == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } dbNote.Title = model.Title; dbNote.Desc = model.Desc; NoteDTO noteModel = new NoteDTO(); noteModel.Title = model.Title; noteModel.Desc = model.Desc; noteModel.ContactId = model.ContactId; this._noteService.Add(dbNote); noteModel.Id = dbNote.Id; result = Request.CreateResponse(HttpStatusCode.OK, noteModel); return(result); }
private static NoteViewModel ConvertNoteDtoToNoteViewModel(NoteDTO x, string userId) { return(new NoteViewModel { Id = x.Id, EntityId = x.EntityId, NoteUser = new NoteUserViewModel { Id = x.NoteUser.Id, Name = x.NoteUser.Name }, Text = x.Text, Date = x.Date, Category = x.Category != null ? new CategoryViewModel { CategoryId = x.Category.CategoryId, Name = x.Category.Name }: null, CurrentUserId = userId, IsCompleted = x.IsCompleted, HasStatus = x.HasStatus }); }
public IActionResult Post([FromBody] NoteDTO note) { var newId = Guid.NewGuid(); note = _noteService.Create(newId, note.Title, note.Content, note.KeyWordsSummary); return(Created($"api/notes/{newId}", note)); }
public OperationStatusInfo <NoteDTO> EditNote(NoteDTO note) { using (new OperationContextScope(InnerChannel)) { return(Channel.EditNote(note)); } }
public CandidateDTO Save(CandidateForm canForm) { CandidateEntity entity = null; NoteDTO note = new NoteDTO(); note.Content = ""; note.Id = 0; canForm.Note = note; note = _noteService.Save(_mapper.Map <NoteEntity>(canForm.Note)); canForm.Note = note; var transaction = _humanManagerContext.Database.BeginTransaction(); try { string folderName = SystemContant.Candidate_Uploading_Path; string uploadPath = _hostingEnvironment.ContentRootPath; string newPath = Path.Combine(uploadPath, folderName); UploadUtil.Uploader uploader = _uploadUtil.DoFileUploading(newPath, canForm.UploadedFile); CandidateEntity newEntity = _mapper.Map <CandidateEntity>(canForm); newEntity.ImageName = uploader.fileName; entity = _humanManagerContext.Candidates.Add(newEntity).Entity; _humanManagerContext.SaveChanges(); transaction.Commit(); CandidateDTO dto = _mapper.Map <CandidateDTO>(entity); return(dto); } catch { transaction.Rollback(); return(null); } }
public NoteDTO EditNote(NoteDTO note) { var oldNoteIndex = _notes.FindIndex(_ => _.Id == note.Id); _notes[oldNoteIndex] = note; return(note); }
/// <summary> /// Gets notes from PCO. /// </summary> /// <param name="modifiedSince">The modified since.</param> /// <returns></returns> public static List <NoteDTO> GetNotes(DateTime?modifiedSince) { var notes = new List <NoteDTO>(); var apiOptions = new Dictionary <string, string> { { "include", "category" } }; var notesQuery = GetAPIQuery(ApiEndpoint.API_NOTES, apiOptions, modifiedSince); if (notesQuery == null) { return(notes); } foreach (var item in notesQuery.Items) { var note = new NoteDTO(item, notesQuery.IncludedItems); notes.Add(note); } return(notes); }
public void GetNotes_IfGetNotes_GetsNotesSuccess() { // arrange const int accountId = 1; const bool trackChanges = false; var note = new Note { UserId = accountId }; var noteDTO = new NoteDTO { Account = new AccountDTO { Id = accountId } }; var notes = new[] { note }; var notesDTO = new[] { noteDTO }; _currentRepositoryMock.Setup(_ => _.FindByCondition(It.IsAny <Expression <Func <Note, bool> > >(), trackChanges)) .Returns(notes.AsQueryable()); _mapperMock.Setup(_ => _.Map <Note, NoteDTO>(note)).Returns(noteDTO); // act var actualNotes = _sut.GetNotes(accountId).ToArray(); // assert _currentRepositoryMock.Verify( _ => _.FindByCondition(It.IsAny <Expression <Func <Note, bool> > >(), trackChanges), Times.Once); _mapperMock.Verify(_ => _.Map <Note, NoteDTO>(note), Times.Once); Assert.True(notesDTO.SequenceEqual(actualNotes)); }
public NoteDTO UpdateNote(NoteDTO note) { var result = DBProviderUtil.FunctionWithProvider(p => { var updateableNote = p.Select <Note>(n => n.Guid == note.Guid); if (updateableNote == null) { return(null); } updateableNote.Title = note.Title; updateableNote.Text = note.Text; p.Update(updateableNote); return(NoteToDTO(updateableNote)); }); if (result == null) { _logger.Error($"Customer's unsuccessful note update attempt: {note}"); } else { _logger.Debug($"Customer's successful note update attempt: {note}"); } return(result); }
public ResponseModel AddNote(NoteDTO dto) { ResponseModel rv; if (IsLoggedIn) { try { NoteService noteService = new NoteService(this.ConnectionString, CurrentUser.UserID); rv = SendResponse(noteService.AddNote(dto), ResponseStatus.Success); } catch (UnauthorizedAccessException) { rv = SendResponse(null, ResponseStatus.AuthorizationError); } catch (Exception ee) { rv = SendExceptionResponse(ee); } } else { rv = SendResponse(null, ResponseStatus.AuthorizationError); } return(rv); }
public NoteDTO AddNote(NoteDTO note, Guid customerGuid) { var result = DBProviderUtil.FunctionWithProvider(p => { var customer = p.Select <Customer>(c => c.Guid == customerGuid); if (customer == null) { return(null); } var isNoteUnique = p.Select <Note>(n => n.Guid == note.Guid) == null; if (!isNoteUnique) { return(null); } var newNote = CreateNewNoteFromDTO(note); customer.AddNote(newNote); p.Update(customer); return(NoteToDTO(newNote)); }); if (result == null) { _logger.Error($"Customer's unsuccessful note addition attempt: customerGuid = {customerGuid}, {note}"); } else { _logger.Debug($"Customer's successful note fetching attempt: customerGuid = {customerGuid}, {note}"); } return(result); }
public NoteDTO AddNote(NoteDTO note) { var maxNoteId = _notes.Max(_ => _.Id); note.Id = ++maxNoteId; _notes.Add(note); return(note); }
public NoteDTO FindOne(long id) { NoteDTO dto = new NoteDTO(); NoteEntity entity = _humanManagerContext.Notes.Find(id); dto = _mapper.Map <NoteDTO>(entity); return(dto); }
public NoteDTO Update(NoteDTO noteToChange) { var changedNote = DTOService.ToEntity <NoteDTO, Note>(noteToChange); uow.NoteRepo.Update(changedNote); uow.Commit(); return(DTOService.ToDTO <Note, NoteDTO>(changedNote)); }
public ActionResult <Api <NoteDTO> > GetOne(long id) { NoteDTO dto = _noteService.FindOne(id); Api <NoteDTO> result = new Api <NoteDTO>(200, dto, "Success", null); return(Ok(result)); }
/// <summary> /// Constructor based on a <see cref="NoteDTO"/> /// </summary> public NoteViewModel(NoteDTO note) { _name = ""; _message = ""; _note = note; Context = App.Context; CanExecute = true; }
public NoteDTO Add(NoteDTO noteToAdd) { var newNote = DTOService.ToEntity <NoteDTO, Note>(noteToAdd); uow.NoteRepo.Insert(newNote); uow.Commit(); return(DTOService.ToDTO <Note, NoteDTO>(newNote)); }
public NoteDTO FindByTitle(string title) { var domain = _noteRepo.Find(x => x.Title == title); var dto = new NoteDTO(); dto.InjectFrom(domain); return(dto); }
public async Task <NoteDTO> GetNoteById(int noteId) { Note note = await _noteRepo.GetFromIdAsync(noteId); NoteDTO noteDTO = ConvertNote(note); return(noteDTO); }
public void CreateNote(NoteDTO newNoteDto) { Note newNote = mapper.Map <NoteDTO, Note>(newNoteDto); Database.Notes.Create(newNote); Database.Save(); }
public void TryToChangeOneNote() { newNote = new NoteDTO(); newNote.Id = 0; newNote.Text = "changedText"; newNote.Title = "changedTitle"; newNote.PublishTime = DateTime.Now; }
public async Task <ActionResult> SubmitNote(NoteDTO noteDTO) { List <ShopModel> shops = await userCosmosDBService.GetShops(noteDTO.Category); if (shops?.Count > 0) { List <ShopModel> nearbyShops = DistanceCalculator.GetDistance(shops, noteDTO.Latitude, noteDTO.Longitude); string body = string.Format("You have received a new order request from {0}", noteDTO.UserPhoneNumber); var phoneGuidList = nearbyShops.Where(s => s.PhoneGuid != null)?.Select(shop => shop.PhoneGuid).ToList(); NotificationData notificationData = null; var data = new Dictionary <string, string>(); data.Add("orderid", "test"); if (phoneGuidList.Count() > 0) { if (phoneGuidList.Count() == 1) { notificationData = new NotificationData() { msgBody = body, msgTitle = "You have received a new order request", tokenList = phoneGuidList[0] //options = data }; } else { notificationData = new NotificationData() { msgBody = body, msgTitle = "You have received a new order request", tokenList = phoneGuidList //options = data }; } pushNotificationService.SendNotification(notificationData); } //Mapping NoteModel note = mapper.Map <NoteModel>(noteDTO); ShopsModel shopsModel = new ShopsModel(); shopsModel.ShopModel = nearbyShops; Model.Shops shopsresult = mapper.Map <Model.Shops>(shopsModel); note.Shops = shopsresult.Shop; //Assigning fields note.NoteTime = DateTime.Now; note.Status = 0; note = await noteCosmosDBService.CreateAndReturnDocumentAsync(note); if (note != null) { return(Ok(mapper.Map <NoteInfo>(note))); } } return(Ok("No shops found with the matching criteria")); }
public Boolean AddNoteService(NoteDTO note) { if (note.Id < 0) { throw new ArgumentOutOfRangeException(); } return(_notesRepository.AddNote(note)); }
public static Note ToNote(this NoteDTO noteDTO) { Note note = new Note(); note.Id = noteDTO.Id; note.DateId = noteDTO.DateId; note.Comment = noteDTO.Comment; return(note); }
public async Task <IActionResult> CreateNote(NoteDTO noteDTO) { Note note = new Note(Title: noteDTO.Title, Content: noteDTO.Content, LanguageId: noteDTO.LanguageID); _context.Notes.Add(note); await _context.SaveChangesAsync(); return(new StatusCodeResult(201)); }
public NoteDTO FindById(int id) { var domain = _noteRepo.Find(id); var dto = new NoteDTO(); dto.InjectFrom(domain); return(dto); }
public IActionResult Addnote([FromBody] NoteDTO note) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _nService.AddNote(note, User.Identity.Name); return(Ok()); }
public int Update(NoteDTO noteToUpdate) { var noteEntity = new Note(); noteEntity.InjectFrom <LoopValueInjection>(noteToUpdate); noteEntity.InjectFrom <MapEnum>(new { EntityState = noteToUpdate.EntityStateDTO }); _noteRepo.Update(noteEntity); return(_unitOfWork.Save()); }
public IActionResult DeleteNote(NoteDTO note, int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _nService.DeleteNote(note, id); return(Ok()); }
public void Save() { CurrentNote.UserId = CurrentUser.Id; var IsSaved = ObjNoteService.Add(CurrentNote); LoadData(PageInfo.Skip, PageInfo.Take, SearchStr); CurrentNote = new NoteDTO(); PageInfo.TotalPageNo = (int)Math.Ceiling((ObjNoteService.GetObjCount(SearchStr) / PageInfo.Take) + 0.5); }
public NotesViewModel() { ObjNoteService = new NoteService(); LoadData(); CurrentNote = new NoteDTO(); saveCommand = new RelayCommand(Save); searchCommand = new RelayCommand(Search); deleteCommand = new RelayCommand(Delete); updateCommand = new RelayCommand(Update); }
/// <summary> /// Constructor /// </summary> public NoteViewModel() { _name = ""; _message = ""; Context = App.Context; if (Context.Note != null) { Console.WriteLine("Context Note: " + Context.Note.Name); _name = Context.Note.Name; _message = Context.Note.Message; _note = Context.Note; } CanExecute = true; }
/// <summary> /// <see cref="INoteManagerService.UpdateNote(NoteDTO, DateTime)"/> /// </summary> /// <param name="note"></param> /// <param name="dateModification"></param> /// <returns></returns> public NoteDTO UpdateNote(NoteDTO note, DateTime dateModification) { Logger logger = new Logger(this.GetType()); logger.Info("[FONTION UPDATE]"); if (note == null || dateModification == null) { throw new ArgumentNullException("UpdateNote : note or dates failed"); } using (var nme = new NoteManagerEntities()) { Note res = nme.Note.Find(note.Id); res.Name = note.Name; res.Message = note.Message; res.DateModification = dateModification; nme.SaveChanges(); logger.Info("[FONTION UPDATE] : note.NAME => ["+note.Name+"]"); return new NoteDTO(res); } }