Ejemplo n.º 1
0
        public NonFinancialAsset GetById(int id, int plannerId)
        {
            NonFinancialAsset nonFinancialAssetObj = new NonFinancialAsset();

            try
            {
                FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
                string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_ALL_BY_ID_API, id, plannerId);

                RestAPIExecutor restApiExecutor = new RestAPIExecutor();

                var restResult = restApiExecutor.Execute <NonFinancialAsset>(apiurl, null, "GET");

                if (jsonSerialization.IsValidJson(restResult.ToString()))
                {
                    nonFinancialAssetObj = jsonSerialization.DeserializeFromString <NonFinancialAsset>(restResult.ToString());
                }
                return(nonFinancialAssetObj);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                return(null);
            }
        }
Ejemplo n.º 2
0
        public IList <NonFinancialAsset> GetByMappedGoalId(int mappedGoalId)
        {
            try
            {
                Logger.LogInfo("Get: Non financial asset process start");
                IList <NonFinancialAsset> lstNonFinancialAsset = new List <NonFinancialAsset>();

                DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(string.Format(SELECT_BY_MAPPED_GOAL_ID, mappedGoalId));
                foreach (DataRow dr in dtAppConfig.Rows)
                {
                    NonFinancialAsset nonfinancialAsset = convertToNonFinancialAssetObject(dr);
                    lstNonFinancialAsset.Add(nonfinancialAsset);
                }
                Logger.LogInfo("Get: Family member information process completed.");
                return(lstNonFinancialAsset);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                return(null);
            }
        }
Ejemplo n.º 3
0
 private NonFinancialAsset convertSelectedRowDataToNonFinancialAsset(DataGridView dtGridNonFinancialAssets)
 {
     if (dtGridNonFinancialAssets.SelectedRows.Count > 0)
     {
         NonFinancialAsset nonFinancialAsset = new NonFinancialAsset();
         DataRow           dr = getSelectedDataRowForNonFinancialAsset(dtGridNonFinancialAssets);
         if (dr != null)
         {
             nonFinancialAsset.Id                   = int.Parse(dr.Field <string>("ID"));
             nonFinancialAsset.Pid                  = int.Parse(dr.Field <string>("PID"));
             nonFinancialAsset.Name                 = dr.Field <string>("NAME");
             nonFinancialAsset.CurrentValue         = double.Parse(dr.Field <string>("CurrentValue"));
             nonFinancialAsset.PrimaryholderShare   = int.Parse(dr.Field <string>("Primaryholdershare"));
             nonFinancialAsset.SecondaryHolderShare = int.Parse(dr.Field <string>("SecondaryHoldershare"));
             nonFinancialAsset.OtherHolderName      = dr.Field <string>("OtherHolderName");
             nonFinancialAsset.OtherHolderShare     = int.Parse(dr.Field <string>("OtherHolderShare"));
             nonFinancialAsset.MappedGoalId         = int.Parse(dr.Field <string>("MappedGoalId"));
             nonFinancialAsset.AssetMappingShare    = int.Parse(dr.Field <string>("AssetMappingShare"));
             nonFinancialAsset.AssetRealisationYear = dr.Field <string>("AssetRealisationYear");
             nonFinancialAsset.Description          = dr.Field <string>("Description");
             nonFinancialAsset.GrowthPercentage     = decimal.Parse(dr["GrowthPercentage"].ToString());
             return(nonFinancialAsset);
         }
     }
     return(null);
 }
Ejemplo n.º 4
0
        public void Update(NonFinancialAsset nonFinancialAsset)
        {
            try
            {
                string clientName = DataBase.DBService.ExecuteCommandScalar(string.Format(GET_CLIENT_NAME_QUERY, nonFinancialAsset.Pid));

                DataBase.DBService.ExecuteCommand(string.Format(UPDATE_QUERY,
                                                                nonFinancialAsset.Name, nonFinancialAsset.CurrentValue,
                                                                nonFinancialAsset.PrimaryholderShare, nonFinancialAsset.SecondaryHolderShare,
                                                                nonFinancialAsset.OtherHolderName, nonFinancialAsset.OtherHolderShare,
                                                                nonFinancialAsset.MappedGoalId, nonFinancialAsset.AssetMappingShare, nonFinancialAsset.AssetRealisationYear,
                                                                nonFinancialAsset.Description,
                                                                nonFinancialAsset.UpdatedOn.ToString("yyyy-MM-dd hh:mm:ss"), nonFinancialAsset.UpdatedBy,
                                                                nonFinancialAsset.GrowthPercentage,
                                                                nonFinancialAsset.Id, nonFinancialAsset.EligibleForInsuranceCover));

                Activity.ActivitiesService.Add(ActivityType.UpdateNonFinancialAsset, EntryStatus.Success,
                                               Source.Server, nonFinancialAsset.UpdatedByUserName, clientName, nonFinancialAsset.MachineName);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                throw ex;
            }
        }
Ejemplo n.º 5
0
        public Result Delete(NonFinancialAsset nonFinancialAsset)
        {
            var result = new Result();

            try
            {
                NonFinancialAssetService nonFinanacialAssetService = new NonFinancialAssetService();
                nonFinanacialAssetService.Delete(nonFinancialAsset);
                result.IsSuccess = true;
            }
            catch (Exception exception)
            {
                result.IsSuccess     = false;
                result.ExceptionInfo = exception;
            }
            return(result);
        }
Ejemplo n.º 6
0
 public void Delete(NonFinancialAsset nonFinancialAsset)
 {
     try
     {
         DataBase.DBService.ExecuteCommand(string.Format(DELETE_QUERY, nonFinancialAsset.Id));
         Activity.ActivitiesService.Add(ActivityType.DeleteNonFinancialAsset, EntryStatus.Success,
                                        Source.Server, nonFinancialAsset.UpdatedByUserName, nonFinancialAsset.Name, nonFinancialAsset.MachineName);
     }
     catch (Exception ex)
     {
         StackTrace st = new StackTrace();
         StackFrame sf = st.GetFrame(0);
         MethodBase currentMethodName = sf.GetMethod();
         LogDebug(currentMethodName.Name, ex);
         throw ex;
     }
 }
Ejemplo n.º 7
0
 public void Delete(NonFinancialAsset nonFinancialAsset)
 {
     try
     {
         FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
         string          apiurl          = Program.WebServiceUrl + "/" + DELETE_NON_FINANCIAL_API;
         RestAPIExecutor restApiExecutor = new RestAPIExecutor();
         var             restResult      = restApiExecutor.Execute <NonFinancialAsset>(apiurl, nonFinancialAsset, "POST");
         MessageBox.Show("Record deleted successfully.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         StackTrace st = new StackTrace();
         StackFrame sf = st.GetFrame(0);
         MethodBase currentMethodName = sf.GetMethod();
         LogDebug(currentMethodName.Name, ex);
         MessageBox.Show("Unable to delete record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Ejemplo n.º 8
0
 public bool Add(NonFinancialAsset nonFinancialAsset)
 {
     try
     {
         FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
         string          apiurl          = Program.WebServiceUrl + "/" + ADD_NON_FINANCIAL_API;
         RestAPIExecutor restApiExecutor = new RestAPIExecutor();
         var             restResult      = restApiExecutor.Execute <NonFinancialAsset>(apiurl, nonFinancialAsset, "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);
     }
 }
Ejemplo n.º 9
0
        private NonFinancialAsset convertToNonFinancialAssetObject(DataRow dr)
        {
            NonFinancialAsset nonFinancialAsset = new NonFinancialAsset();

            nonFinancialAsset.Id                        = dr.Field <int>("ID");
            nonFinancialAsset.Pid                       = dr.Field <int>("PID");
            nonFinancialAsset.Name                      = dr.Field <string>("Name");
            nonFinancialAsset.CurrentValue              = double.Parse(dr["CurrentValue"].ToString());
            nonFinancialAsset.PrimaryholderShare        = dr.Field <int>("Primaryshare");
            nonFinancialAsset.SecondaryHolderShare      = dr.Field <int>("Secondaryshare");
            nonFinancialAsset.OtherHolderName           = dr.Field <string>("OtherHolderName");
            nonFinancialAsset.OtherHolderShare          = dr.Field <int>("OtherHolderShare");
            nonFinancialAsset.MappedGoalId              = dr.Field <int>("MappedGoalId");
            nonFinancialAsset.AssetMappingShare         = dr.Field <decimal>("AssetMappingShare");
            nonFinancialAsset.AssetRealisationYear      = dr.Field <string>("AssetRealisationYear");
            nonFinancialAsset.Description               = dr.Field <string>("Description");
            nonFinancialAsset.GrowthPercentage          = dr.Field <decimal>("GrowthPercentage");
            nonFinancialAsset.EligibleForInsuranceCover = dr.Field <bool>("EligibleForInsuranceCover");
            nonFinancialAsset.UpdatedOn                 = dr.Field <DateTime>("UpdatedOn");
            nonFinancialAsset.UpdatedBy                 = dr.Field <int>("UpdatedBy");
            return(nonFinancialAsset);
        }
Ejemplo n.º 10
0
        public NonFinancialAsset GetByID(int id, int plannerId)
        {
            try
            {
                Logger.LogInfo("Get: Non financial asset by id process start");
                NonFinancialAsset nonFinancialAsset = new NonFinancialAsset();

                DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(string.Format(SELECT_BY_ID, plannerId, id));
                foreach (DataRow dr in dtAppConfig.Rows)
                {
                    nonFinancialAsset = convertToNonFinancialAssetObject(dr);
                }
                Logger.LogInfo("Get: Family member information process completed.");
                return(nonFinancialAsset);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                return(null);
            }
        }