/// <summary> /// Adds the specified entity. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public AttachmentsModel Add(AttachmentsModel entity, string userEmail) { try { var user = LoggedInUser(userEmail); Attachments attachments = new Attachments() { AccountId = entity.AccountId, AttachmentId = entity.AttachmentId, CreationDate = DateTime.Now, DeletedOn = entity.DeletionDate, DownloadUrl = entity.DownloadUrl, ExpiriedOn = entity.ExpiryDate, PurgedOn = entity.ExpiryDate.AddDays(3), Name = entity.Name, TotalSize = entity.TotalSize, Status = entity.Status, UserId = user.Id }; m_AttachmentRepository.Add(attachments); entity.AttachmentId = attachments.AttachmentId; entity.DownloadUrl = attachments.DownloadUrl + "/" + attachments.AttachmentId; this.m_LogService.LogActivity((int)LogsActivityType.FileUpload, "File Uploaded by User" + user.FirstName + " " + user.LastName + "", (int)attachments.AttachmentId, "Attachment", user.Id); return(entity); } 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); } }
/// <summary> /// Adds the specified entity. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public AttachmentModel Add(AttachmentModel Model, string userEmail, string SentBy) { try { //var result = AttachmentMapper<AttachmentsModel, Attachments>.Map(entity); var user = LoggedInUser(userEmail); Attachments attachments = new Attachments() { AccountId = Model.AccountId, AttachmentId = Model.AttachmentId, CreationDate = DateTime.Now, DeletedOn = Model.DeletionDate, DownloadUrl = Model.DownloadUrl, ExpiriedOn = Model.ExpiryDate, PurgedOn = Model.ExpiryDate.AddDays(3), Name = Model.Name, TotalSize = Model.TotalSize, Status = Model.Status, UserId = user.Id, SentBy = SentBy == "Guest" ? (int)AttachmentSentByEnum.GuestSent : (int)AttachmentSentByEnum.WebSent, GuestLinkId = Model.GuestLinkID == 0 ? 0 : Model.GuestLinkID }; m_AttachmentRepository.Add(attachments); Model.AttachmentId = attachments.AttachmentId; Model.DownloadUrl = attachments.DownloadUrl + "/" + attachments.AttachmentId; Model.SentBy = attachments.SentBy == (int)AttachmentSentByEnum.GuestSent ? AttachmentSentByEnum.GuestSent.ToString() : AttachmentSentByEnum.WebSent.ToString(); this.m_LogService.LogActivity((int)LogsActivityType.FileUpload, "File Uploaded by Guest User", (int)attachments.AttachmentId, "Attachment", user.Id); return(Model); } 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); } }