// POST entries/create // Creates a new entry for the user. public async Task <ActionResult> CreateEntry([FromBody] EntryDto entryDto) { var currentUser = await _userService.GetUserAsync(User); if (!(await IsValidEntry("CreateEntry", currentUser, entryDto))) { return(new BadRequestResult()); } // Create the entry. entryDto.When = new DateTime( entryDto.When.Year, entryDto.When.Month, entryDto.When.Day, entryDto.When.Hour, entryDto.When.Minute, entryDto.When.Second); // Remove the miliseconds. var newEntry = _entryService.CreateEntry(currentUser, entryDto); _selfAssessmentService.CreateSelfAssessments( currentUser, entryDto.SkillSetId, entryDto.AssessmentBundle, newEntry); return(Json(newEntry)); }
public async Task <IActionResult> CreateEntry(Guid topicId, [FromBody] EntryDto newEntry) { var result = await entryService.CreateEntry(User.Identity.Name, topicId, newEntry); if (result.IsSuccessed) { return(Ok(result.Data)); } throw result.Exception; }
public HttpResponseMessage CreateEntry(dtoEntry entry) { var output = _entryService.CreateEntry(entry); if (output) { var response = Request.CreateResponse(HttpStatusCode.Created); return(response); } else { throw new HttpResponseException(HttpStatusCode.BadRequest); } }
public async Task <bool> ProcessAsync(TcpClient client, Guid clientId, Request request) { try { var info = JsonConvert.DeserializeObject <Dictionary <string, string> >(request.Body); await m_EntryService.CreateEntry(Guid.Parse(info["idParticipant"]), Guid.Parse(info["contestTasksIdsParticipant"])); return(true); } catch (Exception e) { m_logger.LogError($"Could not add to DataBase : {request.Body}"); return(false); } }
public async Task <IActionResult> CreateEntry([FromBody] JournalEntryDto entryDto) { if (!ModelState.IsValid) { return(BadRequest(new CreateEntryResponseDto { Errors = ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage)) })); } var newEntry = _mapper.Map <JournalEntry>(entryDto); await _entryService.CreateEntry(newEntry); return(StatusCode(201)); }
async Task ExecuteSaveEntryCommand() { SaveInProgress = true; try { var entry = _entryService.CreateEntry(Header, Body); if (entry == null) { _eventAggregator.GetEvent <ErrorMessage>().Publish(new Tuple <ErrorType, string>(ErrorType.EntryCouldNotBeCreated, "")); return; } try { var entryReference = await _entryService.AddEntryToBookAsync(_bookReference, entry); _eventAggregator.GetEvent <InAppInfoMessage>().Publish(new Tuple <InAppInfoMessageType, Dictionary <string, string> >(InAppInfoMessageType.EntrySaved, new Dictionary <string, string>() { { "EntryID", entry.Id } })); bool setAsThumbnail = true; foreach (var attachment in Attachments) { _eventAggregator.GetEvent <InAppInfoMessage>().Publish(new Tuple <InAppInfoMessageType, Dictionary <string, string> >(InAppInfoMessageType.SavingAttachment, new Dictionary <string, string>() { { "AttachmentName", attachment.MediaData.Attachment.FileName } })); var attachmentAdded = await _entryService.AddAttachmentAsync(entryReference, entry, attachment.MediaData.Attachment, attachment.MediaData.Stream, attachment.MediaData.FilePath); if (!attachmentAdded) { _eventAggregator.GetEvent <ErrorMessage>().Publish(new Tuple <ErrorType, string>(ErrorType.AttachmentCouldNotBeSaved, attachment.MediaData.Attachment.FileName)); return; } if (setAsThumbnail) { var thumbnailSet = await _entryService.SetThumbnailAsync(entryReference, entry, attachment.MediaData.Attachment, attachment.MediaData.Stream, attachment.MediaData.FilePath); if (!thumbnailSet) { _eventAggregator.GetEvent <ErrorMessage>().Publish(new Tuple <ErrorType, string>(ErrorType.ThumbnailCouldNotBeSet, attachment.MediaData.Attachment.FileName)); return; } } setAsThumbnail = false; _eventAggregator.GetEvent <InAppInfoMessage>().Publish(new Tuple <InAppInfoMessageType, Dictionary <string, string> >(InAppInfoMessageType.AttachmentSaved, new Dictionary <string, string>() { { "AttachmentName", attachment.MediaData.Attachment.FileName } })); } _eventAggregator.GetEvent <BookEntrySavedMessage>().Publish(new Tuple <EntryReference, Entry>(entryReference, entry)); } catch (EntryCouldNotBeSavedException ex) { _eventAggregator.GetEvent <ErrorMessage>().Publish(new Tuple <ErrorType, string>(ErrorType.EntryCouldNotBeSavedException, ex.Message)); } } finally { SaveInProgress = false; } }