Exemplo n.º 1
0
        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.";
                }
            }
Exemplo n.º 2
0
 public async Task <ActionResult> AcceptFileRequestNotification(AcceptFileRequestNotifictionViewModel AFRN)
 {
     //await NBL.ProcessAcceptedFileRequest(AFRN);
     return(Json(await WDBL.ProcessAcceptedFileRequest(AFRN), JsonRequestBehavior.AllowGet));
     // return RedirectToAction("DisplayUserNotifications", new { TabIndex = AFRN.PageIndex });
 }