public NoteEntity CreateNewNoteForGroup(CreateNoteRequest request, int groupId, int userId) { var noteModel = CreateNoteModel(request, userId); var noteEntity = MapModelToEntity(noteModel); return(Create(noteEntity, groupId, userId)); }
/// <summary>Handles a request</summary> /// <param name="request">The request</param> /// <param name="cancellationToken">Cancellation token</param> /// <returns>Response from the request</returns> public async Task <Result <NoteDto> > Handle(CreateNoteRequest request, CancellationToken cancellationToken) { var note = _mapper.Map <INote>(request.Note); var result = await _noteRepository.CreateAsync(note); return(result.ToResult(_ => _mapper.Map <NoteDto>(result.ValueOrDefault))); }
public void CreateNoteForGroup(CreateNoteRequest request, int groupId, int issuerId) { var user = GetUserForId(issuerId); var group = GetGroupForId(groupId); _notesCreator.CreateNewNoteForGroup(request, group.GroupId, user.UserId); }
public async Task CreateNoteAsync() { Mock <Grafeas.GrafeasClient> mockGrpcClient = new Mock <Grafeas.GrafeasClient>(MockBehavior.Strict); CreateNoteRequest expectedRequest = new CreateNoteRequest { ParentAsProjectName = new ProjectName("[PROJECT]"), NoteId = "noteId2129224840", Note = new Note(), }; Note expectedResponse = new Note { NoteName = new NoteName("[PROJECT]", "[NOTE]"), ShortDescription = "shortDescription-235369287", LongDescription = "longDescription-1747792199", }; mockGrpcClient.Setup(x => x.CreateNoteAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Note>(Task.FromResult(expectedResponse), null, null, null, null)); GrafeasClient client = new GrafeasClientImpl(mockGrpcClient.Object, null); ProjectName parent = new ProjectName("[PROJECT]"); string noteId = "noteId2129224840"; Note note = new Note(); Note response = await client.CreateNoteAsync(parent, noteId, note); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public IActionResult Create([FromBody] CreateNoteRequest noteRequest) { if (noteRequest == null) { return(BadRequest()); } if (string.IsNullOrEmpty(noteRequest.Id)) { noteRequest.Id = Guid.NewGuid().ToString(); } var note = new Note { Id = noteRequest.Id, Tag = noteRequest.Tag, Title = noteRequest.Title, Post = noteRequest.Post, UserId = HttpContext.GetUserId() }; this._noteService.Create(note); var baseUrl = HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.ToUriComponent(); var locationUri = baseUrl + "/" + ApiRoutes.Notes.Get.Replace("{noteId}", noteRequest.Id); var response = new NoteResponse { Id = note.Id, Tag = note.Tag, Title = note.Title, Post = note.Post }; return(Created(locationUri, response)); }
public async Task <Note> PostNewNoteAsync(CreateNoteRequest request) { var dbNote = new NoteDb { Id = Guid.NewGuid(), Description = request.Description, CreatedAt = request.CreatedAt.Value, TargetId = request.TargetId.Value, TargetType = request.TargetType.Value, Author = new AuthorDetails { Email = request.Author?.Email, FullName = request.Author?.FullName }, Categorisation = new Categorisation { Description = request.Categorisation?.Description, Category = request.Categorisation?.Category, SubCategory = request.Categorisation?.SubCategory } }; _logger.LogDebug($"Saving a new note for targetId: {dbNote.TargetId}, targetType: {Enum.GetName(typeof(TargetType), dbNote.TargetType)}"); await _dynamoDbContext.SaveAsync(dbNote).ConfigureAwait(false); return(dbNote.ToDomain()); }
public Task <CreateNoteResponse> CreateAsync(CreateNoteRequest request) { return(Task.FromResult(new CreateNoteResponse() { Title = request.Title, Status = true })); }
public async Task <IActionResult> AddNoteAsync(CreateNoteRequest model, CancellationToken token) { var command = new CreateNoteCommand(model.UserId, model.Text, User.GetIdClaim()); await _commandBus.DispatchAsync(command, token); return(Ok(User.Identity.Name)); }
public async Task <int> CreateNoteAsync(string zoneName, CreateNoteRequest req) { if (string.IsNullOrEmpty(zoneName)) { throw new Client.Exception.ANSClientValidationException("Invalid zone name"); } return((await this.Client.PostAsync <Note>($"/safedns/v1/zones/{zoneName}/notes", req)).ID); }
private Note Map(CreateNoteRequest noteRequest) { Note note = new Note(); note.Description = noteRequest.Description; note.Title = noteRequest.Title; return(note); }
public Task <CreateNoteResponse> CreateNoteAsync(CreateNoteRequest request) { Console.WriteLine($"Receive create note request[Title: {request.Title} -> Content: {request.Content}]"); return(Task.FromResult(new CreateNoteResponse() { Title = request.Title, StatusCode = true })); }
internal static NoteEntity ToEntity(this CreateNoteRequest request) { return(request == null ? null : new NoteEntity { Name = request.Name, Description = request.Description, Note = request.Note }); }
public async Task <Guid> Create(CreateNoteRequest request) { var note = new Note(request.FirstName, request.LastName, request.Phone, request.Email, request.AdditionalInfo); _noteRepository.Create(note); await _noteRepository.SaveChangesAsync(); return(note.Id); }
public void RequestShouldErrorWithNullTargetId() { var model = new CreateNoteRequest() { TargetId = null }; var result = _sut.TestValidate(model); result.ShouldHaveValidationErrorFor(x => x.TargetId); }
public void RequestShouldErrorWithInvalidValidTargetType(int?val) { var model = new CreateNoteRequest() { TargetType = (TargetType?)val }; var result = _sut.TestValidate(model); result.ShouldHaveValidationErrorFor(x => x.TargetType); }
public void RequestShouldErrorWithNullOrEmptyDescription(string description) { var model = new CreateNoteRequest() { Description = description }; var result = _sut.TestValidate(model); result.ShouldHaveValidationErrorFor(x => x.Description); }
public void RequestShouldErrorWithNullCreatedAt() { var model = new CreateNoteRequest() { CreatedAt = null }; var result = _sut.TestValidate(model); result.ShouldHaveValidationErrorFor(x => x.CreatedAt); }
public void RequestShouldNotErrorWithValidTargetType(TargetType tt) { var model = new CreateNoteRequest() { TargetType = tt }; var result = _sut.TestValidate(model); result.ShouldNotHaveValidationErrorFor(x => x.TargetType); }
public async Task <NoteResponse> CreateAsync(CreateNoteRequest request) { NoteEntity _CreatedEntity = await __NoteRepository.CreateAsync(request.ToEntity()); return(_CreatedEntity.ToResponse() ?? new NoteResponse { Success = false, ErrorMessage = $"{GlobalConstants.ERROR_ACTION_PREFIX} create {ENTITY_NAME}." }); }
private CreateNoteModel CreateNoteModel(CreateNoteRequest request, int userId) { var noteModel = new CreateNoteModel { CreatorId = userId, NoteName = request.NoteName, NoteDescription = request.NoteDescription }; return(noteModel); }
public void RequestShouldNotErrorWithValidDescription() { string description = "This description is fine."; var model = new CreateNoteRequest() { Description = description }; var result = _sut.TestValidate(model); result.ShouldNotHaveValidationErrorFor(x => x.Description); }
public void RequestShouldErrorWithAuthorError() { var model = new CreateNoteRequest() { Author = new AuthorDetails() { Email = "dflgkj" } }; var result = _sut.TestValidate(model); result.ShouldHaveValidationErrorFor(x => x.Author.Email); }
/// <summary> /// Creates a note in the <c>CRM</c> /// </summary> /// <param name="crm"> /// The <see cref="AgileCRM"/> instance to be used. /// </param> /// <param name="subject"> /// The subject of the note. /// </param> /// <param name="description"> /// The description of the note. /// </param> /// <param name="contactIds"> /// The related contact identifiers. /// </param> /// <returns> /// The created note /// </returns> public static async Task <Note> CreateContactNoteAsync(AgileCRM crm, string subject, string description, List <long> contactIds) { var createNoteRequest = new CreateNoteRequest() { Subject = subject, Description = description, ContactIds = contactIds, }; var response = await crm.RequestAsync($"notes", HttpMethod.Post, JsonConvert.SerializeObject(createNoteRequest)).ConfigureAwait(false); return(JsonConvert.DeserializeObject <Note>(response)); }
public IActionResult Create(string loginToken, [FromBody] CreateNoteRequest request) { try { _noteService.CreateNote(loginToken, request.model); } catch (Exception e) { LogService.Info <NoteController>(e.StackTrace); return(BadRequest(e.Message)); } return(Ok("Create Note Successfully.")); }
public IActionResult CreateNoteForGroup([FromBody] CreateNoteRequest request, int id) { try { var userId = this.GetUserId(); _noteOperationsHandler.CreateNoteForGroup(request, id, userId); return(Created(string.Empty, null)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
/// <summary> /// Add a public/private note to a ticket. /// /// c.f. https://developers.freshdesk.com/api/#add_note_to_a_ticket /// </summary> /// /// <param name="ticketId"> /// The ticket to add the reply to. /// </param> /// /// <param name="request"> /// Defines the set of properties to set on the note. /// </param> /// /// <param name="cancellationToken"></param> /// /// <returns>The full conversation entry</returns> public async Task <ConversationEntry> CreateNoteAsync( long ticketId, CreateNoteRequest request, CancellationToken cancellationToken = default) { if (request == null) { throw new ArgumentNullException(nameof(request), "Request must not be null"); } return(await _client .ApiOperationAsync <ConversationEntry>(HttpMethod.Post, $"/api/v2/tickets/{ticketId}/notes", request, cancellationToken) .ConfigureAwait(false)); }
public async Task <IActionResult> CreateNote([FromBody] CreateNoteRequest req) { var users = await _context.Users.Include(u => u.Notes).ToArrayAsync(); foreach (var u in users) { if (u.Id.Equals(req.user.Id)) { u.Notes.Add(req.note); await _context.SaveChangesAsync(); return(Ok("note creaed successfuly")); } } return(BadRequest("User not found at creating new note")); }
public void RequestShouldErrorWithDescriptionTooLong() { var msgToRepeat = "This description is to long. "; string description = ""; while (description.Length <= 500) { description += msgToRepeat; } var model = new CreateNoteRequest() { Description = description }; var result = _sut.TestValidate(model); result.ShouldHaveValidationErrorFor(x => x.Description); }
public async Task CreateZoneNoteAsync_ExpectedResult() { CreateNoteRequest req = new CreateNoteRequest() { Notes = "test note" }; IANSSafeDNSClient client = Substitute.For <IANSSafeDNSClient>(); client.PostAsync <Note>("/safedns/v1/zones/example.com/notes", req).Returns(new Note() { ID = 123 }); var ops = new ZoneNoteOperations <Note>(client); int id = await ops.CreateNoteAsync("example.com", req); Assert.AreEqual(123, id); }
public void CreateNote2() { Mock <Grafeas.GrafeasClient> mockGrpcClient = new Mock <Grafeas.GrafeasClient>(MockBehavior.Strict); CreateNoteRequest request = new CreateNoteRequest { ParentAsProjectName = new ProjectName("[PROJECT]"), NoteId = "noteId2129224840", Note = new Note(), }; Note expectedResponse = new Note { NoteName = new NoteName("[PROJECT]", "[NOTE]"), ShortDescription = "shortDescription-235369287", LongDescription = "longDescription-1747792199", }; mockGrpcClient.Setup(x => x.CreateNote(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); GrafeasClient client = new GrafeasClientImpl(mockGrpcClient.Object, null); Note response = client.CreateNote(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }