Ejemplo n.º 1
0
        public JsonResult UploadApprovalLetter(string appid, UploadApprovalLetterViewModel uploadApprovalLetterViewModel)
        {
            string[] arr = Session["UserData"] as string[];
            uploadApprovalLetterViewModel.Comment.ERApplicationId = uploadApprovalLetterViewModel.ForwardApplication.ERApplicationId;
            uploadApprovalLetterViewModel.Comment.UserAccountId   = arr[0];


            uploadApprovalLetterViewModel.ForwardApplication.CommentRefId = uploadApprovalLetterViewModel.Comment.Id;
            uploadApprovalLetterViewModel.ForwardApplication.Sender       = arr[0];
            uploadApprovalLetterViewModel.ForwardApplication.Reciever     = AuditTrailsContext.Collection().Where(x => x.ERApplicationId == appid && x.Is_Active == true && x.StatusId == "S101").FirstOrDefault().SenderId;
            uploadApprovalLetterViewModel.ForwardApplication.FileStatus   = FileStatus.ApprovalLetter;
            uploadApprovalLetterViewModel.ForwardApplication.Is_Active    = true;

            AuditTrails auditTrails = new AuditTrails()
            {
                SenderId        = arr[0],
                ReceiverId      = uploadApprovalLetterViewModel.ForwardApplication.Reciever,
                FileRefId       = uploadApprovalLetterViewModel.ForwardApplication.FileRef,
                ERApplicationId = appid,
                Is_Active       = true,
                StatusId        = "S116"
            };

            AuditTrailsContext.Insert(auditTrails);
            ForwardApplicationContext.Insert(uploadApprovalLetterViewModel.ForwardApplication);
            commentContext.Insert(uploadApprovalLetterViewModel.Comment);

            if (TryValidateModel(uploadApprovalLetterViewModel))
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    commentContext.Commit();
                    ForwardApplicationContext.Commit();
                    AuditTrailsContext.Commit();
                    scope.Complete();
                    return(Json("Successfully Approval Letter Uploaded", JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json("Something Went Wrong! Try Again Later"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult AjaxAdd(string appid, string targetPage, string queryId)
        {
            string[]     arr    = Session["UserData"] as string[];
            string       userid = arr[0];
            object       _genericObject;
            QueryDetails queryDetails;
            QueryMaster  queryMaster;
            Comment      comment;

            switch (targetPage)
            {
            case "QueryCommentRaised":

                queryDetails = new QueryDetails()
                {
                    FileRefId       = Guid.NewGuid().ToString(),
                    ERApplicationId = appid
                };

                QueryCommentViewModel QueryCommentRaised = new QueryCommentViewModel();
                QueryCommentRaised.QueryDetails = queryDetails;


                if (arr[2] == "coordinator")
                {
                    ViewBag.ReciverList = ERAppActiveUsersContext.Collection().Where(x => x.ERApplicationId == appid && x.UserAccountId != userid)
                                          .Select(d => new { ListItemKey = d.UserAccountId, ListItemValue = d.UserAccount.FirstName + " " + d.UserAccount.LastName + " (" + d.UserAccount.UserRole + ")" }).ToList();
                }
                else if (arr[2] == "Consultant Enhanced Recovery")
                {
                    ViewBag.ReciverList = ERAppActiveUsersContext.Collection().Where(x => x.ERApplicationId == appid && x.UserAccountId != userid && x.UserAccount.UserRole == "coordinator")
                                          .Select(d => new { ListItemKey = d.UserAccountId, ListItemValue = d.UserAccount.FirstName + " " + d.UserAccount.LastName + " (" + d.UserAccount.UserRole + ")" }).ToList();
                }
                else if (arr[2] == "operator")
                {
                    ViewBag.ReciverList = ERAppActiveUsersContext.Collection().Where(x => x.ERApplicationId == appid && x.UserAccountId != userid && x.UserAccount.UserRole == "Consultant Enhanced Recovery")
                                          .Select(d => new { ListItemKey = d.UserAccountId, ListItemValue = d.UserAccount.FirstName + " " + d.UserAccount.LastName + " (" + d.UserAccount.UserRole + ")" }).ToList();
                }
                else
                {
                    ViewBag.ReciverList = ERAppActiveUsersContext.Collection().Where(x => x.ERApplicationId == appid && x.UserAccountId != userid && x.UserAccount.UserRole != "operator")
                                          .Select(d => new { ListItemKey = d.UserAccount.Id, ListItemValue = d.UserAccount.FirstName + " " + d.UserAccount.LastName + " (" + d.UserAccount.UserRole + ")" }).ToList();
                }

                _genericObject = QueryCommentRaised;

                break;

            case "QueryCommentForward":

                QueryCommentViewModel QueryCommentForward = new QueryCommentViewModel();
                QueryDetails          qd = QueryDetailsContext.Collection().Where(x => x.Id == queryId).FirstOrDefault();
                queryDetails = new QueryDetails()
                {
                    FileRefId       = Guid.NewGuid().ToString(),
                    ERApplicationId = appid,
                    QueryParentId   = qd.QueryParentId,
                };

                queryMaster = new QueryMaster()
                {
                    Subject = QueryMasterContext.Collection().Where(d => d.Id == qd.QueryParentId).FirstOrDefault().Subject,
                };
                comment = new Comment()
                {
                    Text = commentContext.Collection().Where(c => c.Id == qd.CommentRefId).FirstOrDefault().Text,
                };

                QueryCommentForward.QueryDetails = queryDetails;
                QueryCommentForward.QueryMaster  = queryMaster;
                QueryCommentForward.Comment      = comment;

                QueryUser queryUser = QueryUserContext.Collection().Where(x => x.QueryId == qd.QueryParentId).FirstOrDefault();

                if (arr[2] == "coordinator")
                {
                    //  QueryUserContext.Collection().Where(x=>x.QueryId==queryId)
                    var qmc   = QueryMasterContext.Collection().Where(e => e.ERApplicationId == appid).ToList();
                    var query = from p in qmc
                                join q in qmc on p.Id equals q.QueryParentId
                                select new { pid = p.Id, qid = q.Id };


                    ViewBag.ReciverList = ERAppActiveUsersContext.Collection().Where(x => x.ERApplicationId == appid && x.UserAccountId != userid && x.UserAccountId != queryUser.RecieverId && x.UserAccountId != queryUser.SenderId)
                                          .Select(d => new { ListItemKey = d.UserAccountId, ListItemValue = d.UserAccount.FirstName + " " + d.UserAccount.LastName + " (" + d.UserAccount.UserRole + ")" }).ToList();
                }
                else
                {
                    ViewBag.ReciverList = ERAppActiveUsersContext.Collection().Where(x => x.ERApplicationId == appid && x.UserAccountId != userid && x.UserAccount.UserRole != "operator" && x.UserAccountId != queryUser.RecieverId && x.UserAccountId != queryUser.SenderId)
                                          .Select(d => new { ListItemKey = d.UserAccount.Id, ListItemValue = d.UserAccount.FirstName + " " + d.UserAccount.LastName + " (" + d.UserAccount.UserRole + ")" }).ToList();
                }
                _genericObject = QueryCommentForward;
                break;

            case "QueryCommentReply":

                QueryCommentViewModel QueryCommentReply = new QueryCommentViewModel();

                queryDetails = new QueryDetails()
                {
                    ERApplicationId = appid,
                    QueryParentId   = QueryDetailsContext.Collection().Where(x => x.Id == queryId).Select(d => d.QueryParentId).FirstOrDefault().ToString(),
                    FileRefId       = Guid.NewGuid().ToString()
                };

                QueryCommentReply.QueryDetails = queryDetails;

                _genericObject = QueryCommentReply;
                break;

            case "QueryCommentResolved":
                _genericObject = new QueryCommentViewModel();

                break;

            case "ForwardApplication":
                ForwardAppViewModel forwardAppViewModel = new ForwardAppViewModel();
                ForwardApplication  forwardApplication  = new ForwardApplication();
                //if(arr[2]=="HoD")
                if (arr[2] == UserRoleType.ConsultantEnhancedRecovery.GetDisplayName())
                {
                    ViewBag.ReciverList = UserAccountContext.Collection().Where(x => (x.UserRole == UserRoleType.Coordinator.ToString()) && x.Id != userid)
                                          .Select(d => new { ListItemKey = d.Id, ListItemValue = d.FirstName + " " + d.LastName + " (" + d.UserRole + ")" }).ToList();
                }
                else if (arr[2] == UserRoleType.Coordinator.ToString())
                {
                    int CountForward     = ForwardApplicationContext.Collection().Where(x => x.ERApplicationId == appid && x.Is_Active == true && x.Sender == userid && (x.FileStatus == FileStatus.ReviewAgain || x.FileStatus == FileStatus.Forward)).Count();
                    int CountRecommended = ForwardApplicationContext.Collection().Where(x => x.ERApplicationId == appid && x.Is_Active == true && x.Reciever == userid && x.FileStatus == FileStatus.Recommended).Count();
                    if (CountForward == CountRecommended && CountForward != 0 && CountRecommended != 0)
                    {
                        ViewBag.ReciverList = UserAccountContext.Collection().Where(x => x.UserRole == UserRoleType.DG.ToString() && x.Id != userid)
                                              .Select(d => new { ListItemKey = d.Id, ListItemValue = d.FirstName + " " + d.LastName + " (" + d.UserRole + ")" }).ToList();
                    }
                    else
                    {
                        ViewBag.ReciverList = UserAccountContext.Collection().Where(x => (x.UserRole == UserRoleType.Hod.ToString() ||
                                                                                          x.UserRole == UserRoleType.Coordinator.ToString() || x.UserRole == UserRoleType.ADG.ToString()) && x.Id != userid)
                                              .Select(d => new { ListItemKey = d.Id, ListItemValue = d.FirstName + " " + d.LastName + " (" + d.UserRole + ")" }).ToList();
                    }
                }
                else
                {
                    ViewBag.ReciverList = UserAccountContext.Collection().Where(x => (x.UserRole == UserRoleType.Hod.ToString() ||
                                                                                      x.UserRole == UserRoleType.Coordinator.ToString() || x.UserRole == UserRoleType.ADG.ToString()) && x.Id != userid)
                                          .Select(d => new { ListItemKey = d.Id, ListItemValue = d.FirstName + " " + d.LastName + " (" + d.UserRole + ")" }).ToList();
                }

                forwardApplication.FileRef             = Guid.NewGuid().ToString();
                forwardAppViewModel.ForwardApplication = forwardApplication;
                _genericObject = forwardAppViewModel;
                break;

            case "UploadApprovalLetter":
                UploadApprovalLetterViewModel uploadApprovalLetterViewModel = new UploadApprovalLetterViewModel();
                ForwardApplication            forwardApplication1           = new ForwardApplication()
                {
                    FileRef         = Guid.NewGuid().ToString(),
                    ERApplicationId = appid
                };
                uploadApprovalLetterViewModel.ForwardApplication = forwardApplication1;
                _genericObject = uploadApprovalLetterViewModel;
                break;

            default:
                _genericObject = null;
                break;
            }
            if (null != _genericObject)
            {
                ViewBag.appid = appid;
                return(View(targetPage, _genericObject));
            }
            else
            {
                return(Content("<div class=\"alert alert-danger\" role=\"alert\"> An Error has occured </div>"));
            }
        }