public async Task <Domain.Maybe <Download> > Add(Models.Download download) { var dl = await downloadRepository.Add(download.AppId, download.Latitude, download.Longitude, download.DownloadedAt); if (dl.HasValue) { await hubcontext.Clients.All.SendAsync("new-download"); } return(dl); }
/// <summary> /// Downloads the specified attachment identifier. /// </summary> /// <param name="attachmentId">The attachment identifier.</param> /// <returns></returns> public DownLoadAttachmentModel DownloadAttachment(AttachmentDownloadRequest model, string LoggedInUserEmail) { Download entity = new Download(); DownLoadAttachmentModel DownloadAttachment = new DownLoadAttachmentModel(); byte[] bytes = null; try { var user = LoggedInUser(LoggedInUserEmail); if (IsAuthorizedUser(model)) { var result = this.m_AttachmentRepository.Query <Files>().Where(a => a.AttachmentId == model.AttachmentId).ToList(); if (result.Count == 0) { DownloadAttachment.AttachmentBytes = bytes; DownloadAttachment.FileCount = result.Count; return(DownloadAttachment); } entity.AccessEmail = model.AccessEmail == "" ? null : model.AccessEmail; entity.AccessPassword = model.Password; entity.DownloadDate = DateTime.Now; entity.AttachmentId = model.AttachmentId; entity.UserId = user.Id; m_DownloadRepository.Add(entity); DownloadAttachment = m_FileAssociation.DownloadZipFileFromS3(model.AttachmentId, result); this.m_LogService.LogActivity((int)LogsActivityType.FileUpload, "File Download by User" + user.FirstName + " " + user.LastName + "", (int)model.AttachmentId, "Attachment", user.Id); return(DownloadAttachment); } return(null); } catch (Exception ex) { var message = string.Format("{0} {1} {2}", ex.InnerException == null ? ex.Message : ex.InnerException.Message, Environment.NewLine, ex.StackTrace); throw new Exception(message); } }