public IList<Facility> GetAllFilter(CityStateZip csz, IEnumerable<Offering> offerings, bool wideSearch, int page, int pageSize, out int totalCount) { using (PSS2012DataContext context = this.DataContext) { var search = context.CityStateZips.Where(c => c.City.StartsWith(csz.City) && c.State.StartsWith(csz.State) && c.ZipCode.StartsWith(csz.ZipCode)) .Join(context.Facilities, oid => oid.CityStateZipGuid, iid => iid.CityStateZipGuid, (oid, iid) => iid) .Distinct(); return this.TypeOfCareIntersect(context, this.ExcludePausedAccounts(context, search), offerings, wideSearch) .GetPage<Facility>(page, pageSize, out totalCount); } }
public static DA.CityStateZip ToDataEntity(this BE.CityStateZip beCityStateZip) { DA.CityStateZip cityStateZipResult = new DA.CityStateZip() { CityStateZipGuid = beCityStateZip.CityStateZipGuid, City = beCityStateZip.City, State = beCityStateZip.State, ZipCode = beCityStateZip.ZipCode, }; return cityStateZipResult; }
public void Update(CityStateZip entity) { if (Guid.Empty == entity.CityStateZipGuid) throw new PrimaryKeyMissingException("CityStateZip", entity, "update"); try { using (PSS2012DataContext context = this.DataContext) { // Get the entity to update. CityStateZip cityStateZipToUpdate = GetByPK(entity.CityStateZipGuid); context.CityStateZips.Attach(cityStateZipToUpdate); // Set the new values. cityStateZipToUpdate.City = entity.City; cityStateZipToUpdate.State = entity.State; // plamen: record is located byt zipcode - no need to update //cityStateZipToUpdate.ZipCode = entity.ZipCode; // Perform the update. context.SubmitChanges(); } } catch (System.Data.SqlClient.SqlException ex) { throw this.HandleSqlException(ex); } }
/// <summary> /// Inserts cityStateZip business entity into the data store. /// </summary> /// <param name="entity">The cityStateZip business entity to insert.</param> /// <returns>The cityStateZip identifier.</returns> public CityStateZip Insert(CityStateZip entity) { try { using (PSS2012DataContext context = DataContext) { entity.CityStateZipGuid = Guid.NewGuid(); context.CityStateZips.InsertOnSubmit(entity); context.SubmitChanges(); } return entity; } catch (System.Data.SqlClient.SqlException ex) { throw this.HandleSqlException(ex); } }
//@@NEW public CityStateZip GetByZipCode(string zipCode) { if (string.IsNullOrEmpty(zipCode)) { return null; } try { CityStateZip daCityStateZip = new CityStateZip(); using (PSS2012DataContext context = this.DataContext) { daCityStateZip = ( from items in context.CityStateZips where items.ZipCode == zipCode select items).SingleOrDefault(); } return daCityStateZip; } catch (System.Data.SqlClient.SqlException ex) { throw this.HandleSqlException(ex); } }
public CityStateZip GetByPK(Guid cityStateZipGuid) { if (Guid.Empty == cityStateZipGuid) { return new CityStateZip(); } try { CityStateZip daCityStateZip = new CityStateZip(); using (PSS2012DataContext context = this.DataContext) { daCityStateZip = ( from items in context.CityStateZips where items.CityStateZipGuid == cityStateZipGuid select items).SingleOrDefault(); } if (null == daCityStateZip) { throw new DataAccessException("CityStateZip no longer exists."); } return daCityStateZip; } catch (System.Data.SqlClient.SqlException ex) { throw this.HandleSqlException(ex); } }
public List<CityStateZip> GetAllWithUndefined() { CityStateZip undefinedCityStateZip = new CityStateZip() { CityStateZipGuid = Guid.Empty, City = "Undefined", State = null, ZipCode = null, }; List<CityStateZip> response = this.GetAll().ToList(); response.Add(undefinedCityStateZip); return response; }