public virtual async Task <CompletedTransactionResponses> AsyncRemove(params T[] items) { CompletedTransactionResponses CurrentResponse = await AsyncUpdate(items); CurrentResponse.TransActionType = TransactionType.Delete; return(CurrentResponse); }
public virtual CompletedTransactionResponses Remove(params T[] items) { CompletedTransactionResponses CurrentResponse = Update(items); CurrentResponse.TransActionType = TransactionType.Delete; return(CurrentResponse); }
public async Task <ActionResult> SendWebForm(MailModel Model) { // CompletedTransactionResponses rtnSuccessMessage = CompletedTransactionResponses Trn = await SendCustomMessage(Model); return(Json(Trn, JsonRequestBehavior.AllowGet)); }
public async Task <FileModel> DownloadSelectedFile(ProcessDownloadingOfSelectedFileModel PDOSFM) { //Incomplete must updtea the CompletedTransactionResponses to include the data return. FileModel FM = _FileRepsoitory.GetSingle( //Where a => a.FileID == PDOSFM.FileID, //Include the following in the object graph. a => a.FileBlob, a => a.UserThatDownloadedFile); /* Lock the file that is being downloaded and link the person that downloadedd the file to it. * this is done by inserting a record into the UserThatDownloadedFile table. * This links the user to the file that was downloaded and set the file status from avaiable to Locked in the Files table. * */ if (FM.UserThatDownloadedFile is null) { FM.UserThatDownloadedFile = new UserThatDownloadedFileModel() { FileID = PDOSFM.FileID, UserIDThatDownloadedFIle = PDOSFM.UserIDOfPersonThatDownloadedTheFile, DateDownloaded = DateTime.Now, HasFileBeenReturned = false, EntityState = DomainModels.EntityState.Added }; FM.FileLookupStatusID = (int)WebDocs.Common.Enum.DbLookupTables.EnumFileViewStatuses.Locked; FM.EntityState = DomainModels.EntityState.Modified; CompletedTransactionResponses CTR = await _FileRepsoitory.AsyncUpdate(FM); if (CTR.WasSuccessfull) { return(FM); } else { return(FM); // return View("Error", new HandleErrorInfo(new Exception(), "ContentManagement", "DownLoadSelectedFile")); } } else { return(FM); } }
public static async Task <FileModel> DownloadFile(ProcessDownloadingOfSelectedFileModel PDOSFM) { FileRepository FR = new FileRepository(); FileModel FM = FR.GetSingle( //Where a => a.FileID == PDOSFM.FileID, //Include the following in the object graph. a => a.FileBlob, a => a.UserThatDownloadedFile); /* Lock the file that is being downloaded and link the person that downloadedd the file to it. * this is done by inserting a record into the UserThatDownloadedFile table. * This links the user to the file that was downloaded and set the file status from avaiable to Locked in the Files table. * */ if (FM.UserThatDownloadedFile is null) { FM.UserThatDownloadedFile = new UserThatDownloadedFileModel() { FileID = PDOSFM.FileID, UserIDThatDownloadedFIle = PDOSFM.UserIDOfPersonThatDownloadedTheFile, DateDownloaded = DateTime.Now, HasFileBeenReturned = false, EntityState = DomainModels.EntityState.Added }; FM.FileLookupStatusID = (int)Common.Enum.DbLookupTables.EnumFileViewStatuses.Locked; FM.EntityState = DomainModels.EntityState.Modified; CompletedTransactionResponses CTR = await FR.AsyncUpdate(FM); if (CTR.WasSuccessfull) { return(FM);// File(FM.FileBlob.FileImage, FM.ContentType, FM.FullFileName); } else { return(null); } } else { return(FM); } }
public virtual CompletedTransactionResponses Update(params T[] items) { CompletedTransactionResponses CurrentResponse = new CompletedTransactionResponses() { Message = "", TransActionType = TransactionType.Update, WasSuccessfull = false }; using (var context = new WebDocsEntities()) { using (DbContextTransaction transaction = context.Database.BeginTransaction()) { try { DbSet <T> dbSet = context.Set <T>(); foreach (T item in items) { dbSet.Add(item); foreach (DbEntityEntry <IEntity> entry in context.ChangeTracker.Entries <IEntity>()) { IEntity entity = entry.Entity; entry.State = GetEntityState(entity.EntityState); } } context.SaveChanges(); transaction.Commit(); CurrentResponse.WasSuccessfull = true; CurrentResponse.Message = "Transaction Successfully Completed."; } catch (Exception ex) { transaction.Rollback(); CurrentResponse.Message = "Error occurred. - " + ex.Message; } } } return(CurrentResponse); }
public async Task <CompletedTransactionResponses> ProcessAcceptedFileRequest(AcceptFileRequestNotifictionViewModel AFRN) { //Get Current Notification that was accepted. NotificationModel NM = _NotificationsRepsoitory.GetSingle( a => a.NotificationID == AFRN.NotificationID && a.UserHasAcknowledgement == false); //if Notification Item is returned - update the acknownlagement field and link the file with the person that requested it . if (!(NM is null)) { NM.UserHasAcknowledgement = true; NM.EntityState = DomainModels.EntityState.Modified; CTR = await _NotificationsRepsoitory.AsyncUpdate(NM); if (CTR.WasSuccessfull) { //Link the file to the user so that he can acces the private files. PrivateFilesSharedWithUserModel PFSWUM = new PrivateFilesSharedWithUserModel() { FileID = NM.FileID, UserIDPersonSharedWith = NM.UserIDOfNotificationSender, DateShared = DateTime.Now, EntityState = DomainModels.EntityState.Added }; CTR = await _PrivateFilesSharedWithUserRepository.AsyncAdd(PFSWUM); CTR.Message = CTR.Message + ": File Successfully shared with the requested user."; } else { //Undo the changes that where sent to the database. NM.UserHasAcknowledgement = false; NM.EntityState = DomainModels.EntityState.Modified; await _NotificationsRepsoitory.AsyncUpdate(NM); CTR.Message = CTR.Message + ": No Files where share request failed to process."; } }
public static FileUploadResponses UpdateUploadedFiles(FileModel CurrentFile) { IFileRepository _FileRepsoitory = new FileRepository(); FileUploadResponses Rtn; try { CompletedTransactionResponses CTR = _FileRepsoitory.Update(CurrentFile); if (CTR.WasSuccessfull) { Rtn = new FileUploadResponses() { FileName = CurrentFile.FullFileName, Message = "Successfully Saved", WasSuccessfull = true }; } else { Rtn = new FileUploadResponses() { FileName = CurrentFile.FullFileName, Message = "Failed To Upload - Error : " + CTR.Message, WasSuccessfull = false }; } } catch (Exception ex) { Rtn = new FileUploadResponses() { FileName = CurrentFile.FullFileName, Message = "Failed To Upload - Error : " + ex.Message, WasSuccessfull = false }; } return(Rtn); }
public CompletedTransactionResponses SendFileUploadNotification(ProcessDownloadingOfSelectedFileModel PDOSFM) { FileModel FM = _FileRepsoitory.GetSingle( a => a.FileID == PDOSFM.FileID,//where a => a.FileOwner, a => a.UserThatDownloadedFile, a => a.UserThatDownloadedFile.PersonTahtDownloadedTheFile);//include UsersModel UserThatLoggedOn = _UserRepository.GetSingle(a => a.Id == PDOSFM.UserIDOfPersonThatDownloadedTheFile); NotificationModel NM = _NotificationsRepsoitory.GetSingle( a => a.FileID == PDOSFM.FileID && a.UserHasAcknowledgement == false && a.UserIDOfNotificationSender == PDOSFM.UserIDOfPersonThatDownloadedTheFile && a.UserIDOfNotificationRecipient == FM.UserThatDownloadedFile.UserIDThatDownloadedFIle, //where a => a.RecipientUsers, //include a => a.SendingUsers, a => a.File); //include if (NM is null) { NotificationModel newUploadNotification = new NotificationModel() { FileID = PDOSFM.FileID, UserIDOfNotificationRecipient = FM.UserThatDownloadedFile.UserIDThatDownloadedFIle, UserIDOfNotificationSender = PDOSFM.UserIDOfPersonThatDownloadedTheFile, DateCreated = DateTime.Now, NotificationTypeID = (int)EnumNotificationTypes.Request_File_Upload, UserHasAcknowledgement = false, EntityState = DomainModels.EntityState.Added }; CTR = _NotificationsRepsoitory.Add(newUploadNotification); if (CTR.WasSuccessfull) { WriteToSystemTransactionLog(new SystemTransactionLogsModel() { SystemTransactionTypeID = (int)Common.Enum.DbLookupTables.EnumSystemTransactionTypes.SendFileUploadNotification, UserIDThatPerformedTansaction = PDOSFM.UserIDOfPersonThatDownloadedTheFile, DateTansactionPerformed = DateTime.Now, TransactionComments = UserThatLoggedOn.UserFullName + ": has sent a request to : " + FM.UserThatDownloadedFile.PersonTahtDownloadedTheFile.UserFullName + " to upload to file.", FileID = PDOSFM.FileID }); //add email that will be sent tot the recipient _EmailCacheRepsoitory.AsyncAdd(new EmailCacheModel() { IDOfPersonSender = PDOSFM.UserIDOfPersonThatDownloadedTheFile, IDOfRecipient = FM.UserThatDownloadedFile.PersonTahtDownloadedTheFile.Id, EmailMessage = "A request to upload the following File# " + FM.FileID + " to be uploaded as the following user requires to gain access to the file.<br/>The File that is required name:<b>" + FM.FullFileName + "</b><br/>Regards Web Docs Team.", EmailSubject = "Upload Notification for - (File# " + FM.FileID + ")", HasBeenSent = false, EntityState = DomainModels.EntityState.Added, RetryAttempt = 0 }); } } else // already exists { WriteToSystemTransactionLog(new SystemTransactionLogsModel() { SystemTransactionTypeID = (int)Common.Enum.DbLookupTables.EnumSystemTransactionTypes.SendFileUploadNotification, UserIDThatPerformedTansaction = PDOSFM.UserIDOfPersonThatDownloadedTheFile, DateTansactionPerformed = DateTime.Now, TransactionComments = UserThatLoggedOn.UserFullName + ": has previously sent a request to : " + FM.UserThatDownloadedFile.PersonTahtDownloadedTheFile.UserFullName + " to upload to file, has sent another upload request.", FileID = PDOSFM.FileID }); //add email that will be sent tot the recipient _EmailCacheRepsoitory.AsyncAdd(new EmailCacheModel() { IDOfPersonSender = PDOSFM.UserIDOfPersonThatDownloadedTheFile, IDOfRecipient = FM.UserThatDownloadedFile.PersonTahtDownloadedTheFile.Id, EmailMessage = "A follow up request to kindly upload the following File# " + FM.FileID + " to be uploaded as the following user requires to gain access to the file.<br/>The File that is required name:<b>" + FM.FullFileName + "</b><br/>Regards Web Docs Team.", EmailSubject = "Follow up request to Upload Notification for - (File# " + FM.FileID + ")", HasBeenSent = false, EntityState = DomainModels.EntityState.Added, RetryAttempt = 0 }); } CompletedTransactionResponses RTN = new CompletedTransactionResponses() { Message = "Notification has been sent to : " + FM.UserThatDownloadedFile.PersonTahtDownloadedTheFile.UserFullName, TransActionType = TransactionType.NoneExecuted, WasSuccessfull = true }; return(RTN); }
public async Task <ActionResult> ProcessRequestNotification(ProcessFileRequestNotificationViewModel PFRN) { CompletedTransactionResponses rtnSuccessMessage = await WDBL.ProcessFileRequest(PFRN); return(Json(rtnSuccessMessage, JsonRequestBehavior.AllowGet)); }