Пример #1
0
        /// <summary>
        /// Show Log
        /// </summary>
        /// <param name="loanId"></param>
        /// <returns></returns>
        public ActionResult ShowLog(String loanId, String prospectId, bool source = false)
        {
            UserAccount loggedUser = null;
            int         prospect;

            Int32.TryParse(prospectId, out prospect);

            if (HttpContext != null && HttpContext.Session != null && HttpContext.Session[SessionHelper.UserData] != null)
            {
                loggedUser = ( UserAccount )HttpContext.Session[SessionHelper.UserData];
            }
            else
            {
                // TODO: Handle if user don't have priviledges to see this log
                throw new UnauthorizedAccessException("User is not authorized to access this method!");
            }

            var logItems = LogServiceFacade.RetrieveLogByTypeAndLoanId(new Guid(loanId), prospect, LogItemType.ConversationLog,
                                                                       loggedUser.UserAccountId);

            ViewBag.LogHeader = "Notes";
            ViewBag.Source    = source;

            return(PartialView("Log/_log", new LogViewModel {
                Log = logItems, LoanId = new Guid(loanId)
            }));
        }
Пример #2
0
        /// <summary>
        /// Show Conversation Log (popup)
        /// </summary>
        /// <param name="conversationLogId"></param>
        /// <param name="loanId"></param>
        /// <returns></returns>
        public ActionResult ShowConversationLog(String conversationLogId, String loanId, bool source = false)
        {
            UserAccount loggedUser = null;
            var         logItem    = new LogItem();
            Guid        logId;
            Guid        loan;

            if (HttpContext != null && HttpContext.Session != null && HttpContext.Session[SessionHelper.UserData] != null)
            {
                loggedUser = ( UserAccount )HttpContext.Session[SessionHelper.UserData];
            }
            else
            {
                // TODO: Handle if user don't have priviledges to see this log
                throw new UnauthorizedAccessException("User is not authorized to access this method!");
            }

            Guid.TryParse(loanId, out loan);

            if (Guid.TryParse(conversationLogId, out logId))
            {
                logItem = LogServiceFacade.RetrieveLogByLogId(logId, loggedUser.UserAccountId);
            }

            var subjects = LogServiceFacade.RetrieveConversationSubject();

            if (subjects != null)
            {
                subjects = subjects.OrderBy(s => s.Name).ToList();
            }

            var topics = LogServiceFacade.RetrieveConversationTopic();

            if (topics != null)
            {
                topics = topics.OrderBy(t => t.Name).ToList();
            }
            if (logItem.Id.Equals(Guid.Empty))
            {
                ViewBag.ConversationLogItemHeader = "Add a Note";
            }
            else
            {
                ViewBag.ConversationLogItemHeader = "View a Note";
            }

            ViewBag.Source = source;
            return(PartialView("Log/_conversationLogItem",
                               new LogItemViewModel {
                LogItem = logItem, ConversationSubjects = subjects, ConversationTopics = topics, LoanId = loan
            }));
        }
Пример #3
0
        /// <summary>
        /// Save Conversation Log
        /// </summary>
        /// <param name="loanId"></param>
        /// <param name="logId"></param>
        /// <param name="subject"></param>
        /// <param name="topic"></param>
        /// <param name="comment"></param>
        /// <param name="viewableonborower"></param>
        /// <returns></returns>
        public String SaveConversationLog(String loanId, String logId, String subject, String topic, String comment, String viewableonborower, String prospectId)
        {
            UserAccount loggedUser = null;
            Guid        id;
            Guid        loan;
            Boolean     viewable;
            int         prospect;

            if (HttpContext != null && HttpContext.Session != null && HttpContext.Session[SessionHelper.UserData] != null)
            {
                loggedUser = ( UserAccount )HttpContext.Session[SessionHelper.UserData];
            }
            else
            {
                // TODO: Handle if user don't have priviledges to see this log
                throw new UnauthorizedAccessException("User is not authorized to access this method!");
            }

            Guid.TryParse(logId, out id);
            Guid.TryParse(loanId, out loan);
            Boolean.TryParse(viewableonborower, out viewable);
            Int32.TryParse(prospectId, out prospect);

            var logItem = new LogItem
            {
                Category           = topic,
                LoanId             = loan,
                Comment            = comment,
                ViewableOnBorrower = viewable,
                Subject            = subject,
                Type      = LogItemType.ConversationLog,
                User      = loggedUser.Username,
                ContactId = prospect
            };

            if (!loan.Equals(Guid.Empty) || prospect > 0)
            {
                LogServiceFacade.AddNewConversationLog(logItem, loggedUser.UserAccountId);
                return(Boolean.TrueString);
            }

            return(Boolean.FalseString);
        }