public IHttpActionResult GetUnsatisfiedMortgages(string propertyBBLE) { if (!BAL.BBL.IsValidFormat(propertyBBLE)) { return(BadRequest("Incorrect BBLE - Borough Block Lot & Easement number")); } try { using (ACRISEntities acrisDBEntities = new ACRISEntities()) { List <tfnGetUnsatisfiedMortgages_Result> mortgagesList = acrisDBEntities.tfnGetUnsatisfiedMortgages(propertyBBLE).ToList(); if (mortgagesList == null || mortgagesList.Count <= 0) { return(NotFound()); } return(Ok(Mapper.Map <List <tfnGetUnsatisfiedMortgages_Result>, List <BAL.DeedDocument> >(mortgagesList))); } } catch (Exception e) { Common.Logs.log().Error(string.Format("Error reading AreaAbstract DB{0}", Common.Logs.FormatException(e))); return(Common.HttpResponse.InternalError(Request, "Internal Error in processing request")); } }
/// <summary> /// This function returns a list of unsatisfied mortgages and deletes any mortgage data stored for a mortgaged that is satisfied /// </summary> public static List <tfnGetUnsatisfiedMortgages_Result> GetSynchronizedData(string propertyBBL) { List <tfnGetUnsatisfiedMortgages_Result> uMortgagesList = null; //get all unsatisfied mortgage document records using (ACRISEntities acrisDBEntities = new ACRISEntities()) { uMortgagesList = acrisDBEntities.tfnGetUnsatisfiedMortgages(propertyBBL).ToList(); } //get all mortgage document records stored in webdata locally using (WebDataEntities wDBEntities = new WebDataEntities()) { if (uMortgagesList == null || uMortgagesList.Count <= 0) { wDBEntities.Mortgages.RemoveRange(wDBEntities.Mortgages.Where(x => x.BBL == propertyBBL)); } else { List <WebDataDB.Mortgage> webDataMortgageList = wDBEntities.Mortgages.Where(x => x.BBL == propertyBBL).ToList(); foreach (var wDBMortgage in webDataMortgageList) { bool found = false; foreach (var uMortgage in uMortgagesList) { if (uMortgage.URL == wDBMortgage.MortgageDocumentURI) { found = true; break; } } if (!found) { wDBEntities.Mortgages.Remove(wDBMortgage); } } } wDBEntities.SaveChanges(); } return(uMortgagesList); }