/// <summary> /// Checks the structure exist. /// </summary> /// <param name="facilityStructure"> /// The facility structure. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool CheckStructureExist(FacilityStructure facilityStructure) { using (var facilityStructureRep = UnitOfWork.FacilityStructureRepository) { var iQueryabletransactions = facilityStructureRep.Where( a => a.FacilityStructureId != facilityStructure.FacilityStructureId && a.FacilityId.Equals(facilityStructure.FacilityId) && a.GlobalCodeID == facilityStructure.GlobalCodeID && a.FacilityStructureName.ToLower().Equals(facilityStructure.FacilityStructureName.ToLower()) && a.IsDeleted == false).FirstOrDefault(); return(iQueryabletransactions != null); } }
/// <summary> /// Method to add/Update the Entity in the database. /// </summary> /// <param name="facilityStructure">The facility structure.</param> /// <returns> /// The <see cref="int" />. /// </returns> public int AddUptdateFacilityStructure(FacilityStructure facilityStructure) { using (var facilityStructureRep = UnitOfWork.FacilityStructureRepository) { if (facilityStructure.FacilityStructureId > 0) { if (facilityStructure.GlobalCodeID == 84) { var appointmentId = GetFacilityStructureById(facilityStructure.FacilityStructureId); facilityStructure.ExternalValue4 = appointmentId.ExternalValue4; } facilityStructureRep.UpdateEntity(facilityStructure, facilityStructure.FacilityStructureId); } else { facilityStructureRep.Create(facilityStructure); } return(facilityStructure.FacilityStructureId); } }