public IList <ULIP> GetAll(int plannerId)
        {
            try
            {
                Logger.LogInfo("Get: Mutual fund process start");
                IList <ULIP> lstULIPOption = new List <ULIP>();

                DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(string.Format(SELECT_ALL, plannerId));
                foreach (DataRow dr in dtAppConfig.Rows)
                {
                    ULIP mf = convertToULIP(dr);
                    lstULIPOption.Add(mf);
                }
                Logger.LogInfo("Get: Mutual fund process completed.");
                return(lstULIPOption);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                return(null);
            }
        }
        public void Add(ULIP ULIP)
        {
            try
            {
                string clientName = DataBase.DBService.ExecuteCommandScalar(string.Format(SELECT_ID, ULIP.Id));

                DataBase.DBService.BeginTransaction();
                DataBase.DBService.ExecuteCommandString(string.Format(INSERT_ULIP,
                                                                      ULIP.Pid, ULIP.InvesterName, ULIP.SchemeName,
                                                                      ULIP.FolioNo,
                                                                      ULIP.Nav, ULIP.Units, ULIP.EquityRatio,
                                                                      ULIP.GoldRatio, ULIP.DebtRatio, ULIP.SIP, ULIP.FreeUnit,
                                                                      ULIP.RedumptionAmount, ULIP.GoalID,
                                                                      ULIP.CreatedOn.ToString("yyyy-MM-dd hh:mm:ss"), ULIP.CreatedBy,
                                                                      ULIP.UpdatedOn.ToString("yyyy-MM-dd hh:mm:ss"), ULIP.UpdatedBy,
                                                                      ULIP.FirstHolder, ULIP.SecondHolder, ULIP.Nominee,
                                                                      ULIP.InvestmentReturnRate), true);

                Activity.ActivitiesService.Add(ActivityType.CreateULIP, EntryStatus.Success,
                                               Source.Server, ULIP.UpdatedByUserName, "ULIP", ULIP.MachineName);
                DataBase.DBService.CommitTransaction();
            }
            catch (Exception ex)
            {
                DataBase.DBService.RollbackTransaction();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                throw ex;
            }
        }
        private ULIP convertToULIP(DataRow dr)
        {
            ULIP ULIP = new ULIP();

            ULIP.Id               = dr.Field <int>("ID");
            ULIP.Pid              = dr.Field <int>("PID");
            ULIP.InvesterName     = dr.Field <string>("InvesterName");
            ULIP.SchemeName       = dr.Field <string>("SchemeName");
            ULIP.FolioNo          = dr.Field <string>("FolioNo");
            ULIP.Nav              = float.Parse(dr["NAV"].ToString());
            ULIP.Units            = dr.Field <int>("units");
            ULIP.EquityRatio      = float.Parse(dr["EquityRatio"].ToString());
            ULIP.GoldRatio        = float.Parse(dr["GoldRatio"].ToString());
            ULIP.DebtRatio        = float.Parse(dr["DebtRatio"].ToString());
            ULIP.SIP              = double.Parse(dr["SIP"].ToString());
            ULIP.FreeUnit         = dr.Field <int>("FreeUnits");
            ULIP.RedumptionAmount = double.Parse(dr["RedumptionAmount"].ToString());
            ULIP.GoalID           = dr.Field <int>("GoalId");

            ULIP.UpdatedBy         = dr.Field <int>("UpdatedBy");
            ULIP.UpdatedOn         = dr.Field <DateTime>("UpdatedOn");
            ULIP.UpdatedByUserName = dr.Field <string>("UpdatedByUserName");

            ULIP.FirstHolder          = dr.Field <string>("FirstHolder");
            ULIP.SecondHolder         = dr.Field <string>("SecondHolder");
            ULIP.Nominee              = dr.Field <string>("Nominee");
            ULIP.InvestmentReturnRate = float.Parse(dr["InvestmentReturnRate"].ToString());
            return(ULIP);
        }
        public Result Delete(ULIP ulip)
        {
            var result = new Result();

            try
            {
                ULIPService ULIPService = new ULIPService();
                ULIPService.Delete(ulip);
                result.IsSuccess = true;
            }
            catch (Exception exception)
            {
                result.IsSuccess     = false;
                result.ExceptionInfo = exception;
            }
            return(result);
        }
 internal bool Update(ULIP ULIP)
 {
     try
     {
         FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
         string          apiurl          = Program.WebServiceUrl + "/" + UPDATE_ULIP_API;
         RestAPIExecutor restApiExecutor = new RestAPIExecutor();
         var             restResult      = restApiExecutor.Execute <ULIP>(apiurl, ULIP, "POST");
         return(true);
     }
     catch (Exception ex)
     {
         StackTrace st = new StackTrace();
         StackFrame sf = st.GetFrame(0);
         MethodBase currentMethodName = sf.GetMethod();
         LogDebug(currentMethodName.Name, ex);
         return(false);
     }
 }
        public ULIP Get(int id)
        {
            try
            {
                Logger.LogInfo("Get: Mutual fund by id process start");
                ULIP ULIP = new ULIP();

                DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(string.Format(SELECT_ID, id));
                foreach (DataRow dr in dtAppConfig.Rows)
                {
                    ULIP = convertToULIP(dr);
                }
                Logger.LogInfo("Get: Mutual fund by id process completed");
                return(ULIP);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                return(null);
            }
        }
        public void Delete(ULIP ULIP)
        {
            try
            {
                string clientName = DataBase.DBService.ExecuteCommandScalar(string.Format(SELECT_ID, ULIP.Id));

                DataBase.DBService.BeginTransaction();
                DataBase.DBService.ExecuteCommandString(string.Format(DELETE_ULIP,
                                                                      ULIP.Id), true);

                Activity.ActivitiesService.Add(ActivityType.DeleteULIP, EntryStatus.Success,
                                               Source.Server, ULIP.UpdatedByUserName, "ULIP", ULIP.MachineName);
                DataBase.DBService.CommitTransaction();
            }
            catch (Exception ex)
            {
                DataBase.DBService.RollbackTransaction();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                throw ex;
            }
        }