Example #1
0
        public int Insert(CaseDal casedata, List <int> raceEthnicityList, List <int> vulnerabilitiesList, List <CaseLawEnforcementDal> lawEnforcementList)
        {
            var newId = -1;

            if (casedata.CountyId <= 0)
            {
                casedata.CountyId = 177;
            }
            if (casedata.SchoolId <= 0)
            {
                casedata.SchoolId = 1;
            }
            using (var conn = Database.GetConnection())
            {
                var exists = conn.Query <int>("select id from case_data where mcm_number=@number", new { number = casedata.MCMNumber }).FirstOrDefault();
                if (exists > 0)
                {
                    throw new InvalidOperationException($"MCM Number {casedata.MCMNumber} already exists in database");
                }

                conn.Execute(_insertSql, casedata);
                var result = conn.Query <CaseDal>(_selectSql + " where mcm_number=@number;", new { number = casedata.MCMNumber }).FirstOrDefault();
                newId = result == null ? -1 : result.Id;
            }
            if (newId > -1)
            {
                SaveRaceEthnicity(newId, raceEthnicityList);
                SaveVulnerabilities(newId, vulnerabilitiesList);
                SaveCaseLawEnforcementList(newId, lawEnforcementList);
            }
            return(newId);
        }
Example #2
0
        protected override void DataPortal_Update()
        {
            var dal = new Dal.Cases();

            using (BypassPropertyChecks)
            {
                var data = new Dal.CaseDal();
                Csla.Data.DataMapper.Map(this, data, ignoreList);
                dal.Update(data, RaceEthnicityList, VulnerabilityList, CaseLawEnforcementList.Select(r => new Dal.CaseLawEnforcementDal {
                    AgencyId = r.Key, Denial = r.Value
                }).ToList());
            }
        }
Example #3
0
        private void Child_Fetch(Dal.CaseDal data)
        {
            Id              = data.Id;
            MCMNumber       = data.MCMNumber;
            IntakeDate      = data.IntakeDate;
            LastSeen        = data.LastSeen;
            ReportedMissing = data.ReportedMissing;
            Age             = data.Age;
            Gender          = data.Gender;
            PeopleServed    = data.PeopleServed;
            City            = data.City;
            CountyId        = data.CountyId;
            State           = data.State;
            StartCaseType   = data.StartCaseType;
            EndCaseType     = data.EndCaseType;
            Disposition     = data.Disposition;
            CloseDate       = data.CloseDate;
            ReferralType    = data.ReferralType;
            CaseStatus      = data.CaseStatus;
            SchoolId        = data.SchoolId;

            var cdal = new Dal.Counties();
            var c    = cdal.Get(CountyId);

            if (c != null)
            {
                County = c.Name;
            }
            else
            {
                County = "n/a";
            }

            var sdal = new Dal.Schools();
            var s    = sdal.Get(SchoolId);

            if (s != null)
            {
                School = s.Name;
            }
            else
            {
                School = "n/a";
            }
        }
Example #4
0
 public void Update(CaseDal casedata, List <int> raceEthnicityList, List <int> vulnerabilitiesList, List <CaseLawEnforcementDal> lawEnforcementList)
 {
     if (casedata.CountyId <= 0)
     {
         casedata.CountyId = 177;
     }
     if (casedata.SchoolId <= 0)
     {
         casedata.SchoolId = 1;
     }
     using (var conn = Database.GetConnection())
     {
         conn.Execute(_updateSql, casedata);
     }
     SaveRaceEthnicity(casedata.Id, raceEthnicityList);
     SaveVulnerabilities(casedata.Id, vulnerabilitiesList);
     SaveCaseLawEnforcementList(casedata.Id, lawEnforcementList);
 }