public GetAttachmentsResponse GetAllAttachments(GetAttachmentsRequest request) { GetAttachmentsResponse response = new GetAttachmentsResponse(); IEnumerable <Attachment> attachments = attachmentRepository.FindAllAttachments(request.ContactId, request.OpportunityID, request.Page, request.Limit, request.PageNumber); AttachmentActivityAnalyzer analyser = new AttachmentActivityAnalyzer(attachments, request.DateFormat); response.Attachments = Mapper.Map <IEnumerable <Attachment>, IEnumerable <AttachmentViewModel> >(analyser.GenerateAnalysis()); response.TotalRecords = attachmentRepository.TotalNumberOfAttachments(request.ContactId, request.OpportunityID, request.Page); return(response); }
public async Task <IActionResult> GetAttachments([FromBody] GetAttachmentsRequest request) { try { var result = await messagesService.GetAttachments( request.kind, request.conversationId, ClaimsExtractor.GetUserIdClaim(User.Claims), request.offset, request.count); return(Ok(new ResponseApiModel <List <Message> > { IsSuccessfull = true, ErrorMessage = null, Response = result })); } catch (InvalidDataException ex) { return(BadRequest(new ResponseApiModel <bool> { IsSuccessfull = false, ErrorMessage = ex.Message })); } catch (UnauthorizedAccessException ex) { return(StatusCode((int)HttpStatusCode.Forbidden, new ResponseApiModel <bool> { IsSuccessfull = false, ErrorMessage = ex.Message })); } catch (KeyNotFoundException ex) { return(NotFound(new ResponseApiModel <bool> { IsSuccessfull = false, ErrorMessage = ex.Message })); } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, new ResponseApiModel <bool> { IsSuccessfull = false })); } }