public FacilityAudit GetByPK(Guid facilityAuditGuid) { if (Guid.Empty == facilityAuditGuid) { return new FacilityAudit(); } try { FacilityAudit daFacilityAudit = new FacilityAudit(); using (PSS2012DataContext context = this.DataContext) { daFacilityAudit = ( from items in context.FacilityAudits where items.FacilityAuditGuid == facilityAuditGuid select items).SingleOrDefault(); } if (null == daFacilityAudit) { throw new DataAccessException("FacilityAudit no longer exists."); } return daFacilityAudit; } catch (System.Data.SqlClient.SqlException ex) { throw this.HandleSqlException(ex); } catch (Exception ex) { throw ex; } }
public List<FacilityAudit> GetAllWithUndefined() { FacilityAudit undefinedFacilityAudit = new FacilityAudit() { FacilityAuditGuid = Guid.Empty, FacilityGuid = Guid.Empty, FacilityID = 0, FacilityName = "Undefined", Exerpt = null, Description = null, Address = null, CityStateZipGuid = Guid.Empty, PhoneNumber = null, Email = null, Website = null, ClientGuid = Guid.Empty, ListingTypeGuid = Guid.Empty, PublicPhotoFileUri = null, DateModified = default(DateTime), }; List<FacilityAudit> response = this.GetAll().ToList(); response.Add(undefinedFacilityAudit); return response; }
/// <summary> /// Inserts facilityAudit business entity into the data store. /// </summary> /// <param name="entity">The facilityAudit business entity to insert.</param> /// <returns>The facilityAudit identifier.</returns> public FacilityAudit Insert(FacilityAudit entity) { //@@NEW - changed return type to entity type. try { using (PSS2012DataContext context = DataContext) { entity.FacilityAuditGuid = Guid.NewGuid(); //@@NEW entity.DateModified = DateTime.Now; context.FacilityAudits.InsertOnSubmit(entity); context.SubmitChanges(); } //@@NEW - returning full entity. return entity; } catch (System.Data.SqlClient.SqlException ex) { throw this.HandleSqlException(ex); } }
public static DA.FacilityAudit ToDataEntity(this BE.FacilityAudit beFacilityAudit) { DA.FacilityAudit facilityAuditResult = new DA.FacilityAudit() { FacilityAuditGuid = beFacilityAudit.FacilityAuditGuid, FacilityGuid = beFacilityAudit.FacilityGuid, FacilityID = beFacilityAudit.FacilityID, FacilityName = beFacilityAudit.FacilityName, Exerpt = beFacilityAudit.Exerpt, Description = beFacilityAudit.Description, Address = beFacilityAudit.Address, CityStateZipGuid = beFacilityAudit.CityStateZipGuid, PhoneNumber = beFacilityAudit.PhoneNumber, Email = beFacilityAudit.Email, Website = beFacilityAudit.Website, ClientGuid = beFacilityAudit.ClientGuid, ListingTypeGuid = beFacilityAudit.ListingTypeGuid, PublicPhotoFileUri = beFacilityAudit.PublicPhotoFileUri, DateModified = beFacilityAudit.DateModified, Latitude = beFacilityAudit.Latitude, Longitude = beFacilityAudit.Longitude, Price=beFacilityAudit.Price }; return facilityAuditResult; }