Example #1
0
        public virtual IList <ICallReportVO> RetrieveCallReportTaskList(int loginId, bool isInitiator)
        {
            if (loginId != 0)
            {
                string query = RETRIEVE_CALL_REPORT_TASK_LIST;
                if (isInitiator)
                {
                    query += " AND st.initiator_id = @LoginId AND st.initiator_id = st.current_owner_id ";
                }
                else
                {
                    query += " AND (st.initiator_id = @LoginId OR st.current_owner_id = @LoginId) ";
                    query += " AND st.initiator_id <> st.current_owner_id ";
                }
                query += " ORDER BY sccr.date_of_call ";

                return((IList <ICallReportVO>)
                       AdoTemplate.QueryWithRowMapperDelegate(
                           CommandType.Text,
                           query,
                           delegate(IDataReader dataReader, int rowNum)
                {
                    ICallReportVO callReport = new CallReportVO();
                    callReport.Id = dataReader.GetSafeInt32("id");
                    callReport.Customer = new CustomerVO()
                    {
                        Id = dataReader.GetSafeInt32("customer_id"),
                        CustomerType = dataReader.GetSafeString("customer_type"),
                        CustomerName = dataReader.GetSafeString("customer_name")
                    };
                    callReport.ReferenceNo = dataReader.GetSafeString("ref_no");
                    callReport.CallDate = dataReader.GetSafeDateTime("date_of_call");
                    callReport.CallPurpose = new CodeValueVO()
                    {
                        Description = dataReader.GetSafeString("purpose_desc")
                    };
                    callReport.Owner = new UserVO()
                    {
                        FullName = dataReader.GetSafeString("owner_name")
                    };
                    callReport.CurrentRecipient = new UserVO()
                    {
                        FullName = dataReader.GetSafeString("current_recipient")
                    };
                    callReport.ProcessDefinition = dataReader.GetSafeString("process_definition");

                    return callReport;
                },
                           "LoginId",
                           DbType.Int32,
                           0,
                           loginId
                           ));
            }

            return(null);
        }
        public ActionResult ProcessCallReport(CallReportViewModel model, ActionType actionType)
        {
            Logger.Debug("SaveCallReport|Action type: " + actionType);

            if (actionType == ActionType.Process)
            {
                try
                {
                    ICallReportVO callReport = (CallReportVO)
                                               CallReportMapper.Map(model, typeof(CallReportViewModel), typeof(CallReportVO));

                    ICallReportVO sessionCallReport = (ICallReportVO)Session["SessionCallReport"];
                    if (callReport.Id == 0 || sessionCallReport == null)
                    {
                        sessionCallReport = new CallReportVO();
                    }

                    AccessorUtil.copyValue(callReport, sessionCallReport, CallReportVO.EXCLUDE_COPY);

                    sessionCallReport.LastUpdateBy = User.Identity.Name;

                    ICustomerVO sessionCustomer = (ICustomerVO)Session["SessionCustomer"];
                    sessionCallReport.Customer = sessionCustomer;

                    sessionCallReport = CallReportManager.ProcessCallReport(sessionCallReport, model.Action);

                    model = (CallReportViewModel)
                            CallReportMapper.Map(sessionCallReport, typeof(ICallReportVO), typeof(CallReportViewModel));

                    Session["SessionCallReport"]   = sessionCallReport;
                    TempData["MessageType"]        = MessageType.Success;
                    TempData["MessageDescription"] = CommonResources.MessageSaveSuccess;
                }
                catch (Exception exception)
                {
                    Logger.Debug("Exception encountered: " + exception.StackTrace);

                    TempData["MessageType"]        = MessageType.Error;
                    TempData["MessageDescription"] = CommonResources.MessageSaveError + exception.Message;
                }

                TempData["CallReportDetailModel"] = model;
                return(RedirectToAction("ViewCallReportDetails"));
            }

            return(RedirectToAction("ViewCallReportList"));
        }