HealthInformationProgram.Data.Repositories.SupplementalDiagnosisRepository.CreateSupplementalDiagnosis C# (CSharp) Method

CreateSupplementalDiagnosis() public method

public CreateSupplementalDiagnosis ( lkup_splmtl_diag entity ) : int
entity HealthInformationProgram.Data.Tables.lkup_splmtl_diag
return int
        public int CreateSupplementalDiagnosis(lkup_splmtl_diag entity)
        {
            try
            {

                using ( var ctx = new ClinicDataContext(connString) )
                {
                    IdentityInsertOn<lkup_splmtl_diag>(ctx, entity);
                    ctx.Entry(entity).State = System.Data.Entity.EntityState.Added;
                    int result = ctx.SaveChanges();

                    return result;
                }
            }
            catch ( DbEntityValidationException ex )
            {
                throw ex;
            }
            catch ( EntityException ex )
            {
                throw ex;
            }
            catch ( Exception ex )
            {
                throw ex;
            }
        }

Usage Example

Example #1
0
        public int CreateSupplementalDiagnosis(SupplementalDiagnosisModel model)
        {
            var repo = new SupplementalDiagnosisRepository();
            var dataModel = new HealthInformationProgram.Data.Tables.lkup_splmtl_diag();
            //dataModel.splmtl_diag_id = null;// Convert.ToDecimal(model.SupplementalDiagnosisId);
            dataModel.diag_id = Convert.ToDecimal(model.DiagnosisId);
            dataModel.splmtl_diag_stat = model.Status;
            dataModel.splmtl_diag_descn = model.SupplementalDiagnosisDescription;
            dataModel.user_intrfc_sort_ord = Convert.ToDecimal(model.SortOrder);
            dataModel.splmtl_diag_strt_eff_dt = Convert.ToDateTime(model.SupplementalDiagnosisEffectiveStartDate);
            dataModel.splmtl_diag_end_eff_dt = Convert.ToDateTime(model.SupplementalDiagnosisEffectiveEndDate);
            dataModel.rec_creat_dt = DateTime.Now;
            dataModel.rec_creat_user_id_cd = model.CreatedBy;
            dataModel.rec_updt_dt = DateTime.Now;
            dataModel.rec_updt_user_id_cd = model.UpdatedBy;

            try
            {

                var returnCode = repo.CreateSupplementalDiagnosis(dataModel);
                return returnCode;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }