예제 #1
0
        public async static Task <IDTO> AddUpdateMode(Attachment attachment)
        {
            string SPName  = "";
            string message = "";
            OracleDynamicParameters oracleParams = new OracleDynamicParameters();
            ComplateOperation <int> complate     = new ComplateOperation <int>();


            if (attachment.ID.HasValue)
            {
                oracleParams.Add(AttachmentsSpParams.PARAMETER_ID, OracleDbType.Int64, ParameterDirection.Input, (object)attachment.ID ?? DBNull.Value);

                SPName  = AttachmentsSpName.SP_UPADTE_ATTACHMENT;
                message = "Updated Successfully";
            }
            else
            {
                oracleParams.Add(AttachmentsSpParams.PARAMETER_ID, OracleDbType.Int64, ParameterDirection.Output);
                SPName  = AttachmentsSpName.SP_INSERT_ATTACHMENT;
                message = "Inserted Successfully";
            }

            oracleParams.Add(AttachmentsSpParams.PARAMETER_SERIAL, OracleDbType.Int64, ParameterDirection.Input, (object)attachment.Serial ?? DBNull.Value);
            attachment.FullPath = GenerateFiles.FilePath(attachment.Path, attachment.Type);
            if (attachment.File != null)
            {
                string path = "";
                if (attachment.DocumentID.HasValue)
                {
                    path = await GenerateFiles.InsertFileAsync(attachment.File, attachment.FullPath, attachment.DocumentID.ToString());
                }
                if (attachment.RiskID.HasValue)
                {
                    path = await GenerateFiles.InsertFileAsync(attachment.File, attachment.FullPath, attachment.RiskID.ToString());
                }
                if (attachment.ClaimID.HasValue)
                {
                    path = await GenerateFiles.InsertFileAsync(attachment.File, attachment.FullPath, attachment.ClaimID.ToString());
                }
                attachment.FullPath = path;
            }
            else
            {
                if (!string.IsNullOrEmpty(attachment.AttachedPath))
                {
                    attachment.FullPath = attachment.AttachedPath;
                }
                else
                {
                    attachment.FullPath = "";
                }
            }
            oracleParams.Add(AttachmentsSpParams.PARAMETER_ATTACHED_PATH, OracleDbType.Varchar2, ParameterDirection.Input, (object)attachment.FullPath ?? DBNull.Value);

            oracleParams.Add(AttachmentsSpParams.PARAMETER_CREATED_BY, OracleDbType.Varchar2, ParameterDirection.Input, (object)attachment.CreatedBy ?? DBNull.Value);
            oracleParams.Add(AttachmentsSpParams.PARAMETER_CREATION_DATE, OracleDbType.Date, ParameterDirection.Input, (object)attachment.CreationDate ?? DBNull.Value);
            oracleParams.Add(AttachmentsSpParams.PARAMETER_MODIFIED_BY, OracleDbType.Varchar2, ParameterDirection.Input, (object)attachment.ModifiedBy ?? DBNull.Value);
            oracleParams.Add(AttachmentsSpParams.PARAMETER_MODIFICATION_DATE, OracleDbType.Date, ParameterDirection.Input, (object)attachment.ModificationDate ?? DBNull.Value);
            oracleParams.Add(AttachmentsSpParams.PARAMETER_UW_DOC_ID, OracleDbType.Int64, ParameterDirection.Input, (object)attachment.DocumentID ?? DBNull.Value);
            oracleParams.Add(AttachmentsSpParams.PARAMETER_UW_RISK_ID, OracleDbType.Int64, ParameterDirection.Input, (object)attachment.RiskID ?? DBNull.Value);
            oracleParams.Add(AttachmentsSpParams.PARAMETER_IS_RECEIVED, OracleDbType.Int64, ParameterDirection.Input, (object)attachment.IsReceived ?? DBNull.Value);
            oracleParams.Add(AttachmentsSpParams.PARAMETER_RECEIVED_DATE, OracleDbType.Date, ParameterDirection.Input, (object)attachment.ReceivedDate ?? DBNull.Value);
            oracleParams.Add(AttachmentsSpParams.PARAMETER_REMARKS, OracleDbType.Varchar2, ParameterDirection.Input, (object)attachment.Remarks ?? DBNull.Value);
            oracleParams.Add(AttachmentsSpParams.PARAMETER_ST_PRD_ATT_ID, OracleDbType.Int64, ParameterDirection.Input, (object)attachment.ProductAttachmentID ?? DBNull.Value);
            oracleParams.Add(AttachmentsSpParams.PARAMETER_CLM_ID, OracleDbType.Int64, ParameterDirection.Input, (object)attachment.ClaimID ?? DBNull.Value);
            oracleParams.Add(AttachmentsSpParams.PARAMETER_LOC_LEVEL, OracleDbType.Int64, ParameterDirection.Input, (object)attachment.Level ?? DBNull.Value);


            if (await NonQueryExecuter.ExecuteNonQueryAsync(SPName, oracleParams) == -1)
            {
                complate.message = message;
                complate.ID      = oracleParams.Get(0);
            }
            else
            {
                complate.message = "Operation Failed";
            }



            return(complate);
        }