public void DeleteFacilityOffering(DC.FacilityOffering request) { try { BL.FacilityOfferingLogic facilityOfferingLogic = new BL.FacilityOfferingLogic(); BE.FacilityOffering entity = request.ToBusinessEntity(); facilityOfferingLogic.DeleteFacilityOffering(entity); } catch (BE.FacilityOfferingNotFoundException ex) { FC.DefaultFaultContract fault = new FC.DefaultFaultContract(); fault.ErrorMessage = String.Format("Unable to delete FacilityOffering data for FacilityGuid '{0}' and OfferingGuid '{1}'.", request.FacilityGuid.ToString(), request.OfferingGuid.ToString()); throw new FaultException<FC.DefaultFaultContract>(fault, new FaultReason(ex.Message)); } }
public void DeleteFacilityFromOffering(Guid offeringGuid, Guid facilityGuid) { try { BE.FacilityOffering joinRowToDelete = new BE.FacilityOffering(offeringGuid, facilityGuid); BL.FacilityOfferingLogic joinLogic = new BL.FacilityOfferingLogic(); joinLogic.DeleteFacilityOffering(joinRowToDelete); } catch (Exception ex) { FC.FacilityOfferingFault fault = new FC.FacilityOfferingFault(); fault.OfferingGuid = offeringGuid; fault.FacilityGuid = facilityGuid; fault.ErrorMessage = String.Format("Unable to remove facility '{0}' from offering '{1}'.", facilityGuid, offeringGuid); throw new FaultException<FC.FacilityOfferingFault>(fault, new FaultReason(ex.Message)); } }
public bool Delete(Guid facilityGuid, string email) { bool success = false; FacilityLogic facilityLogic = new FacilityLogic(); BE.Facility facility = facilityLogic.GetFacilityByFacilityGuid(facilityGuid); ClientLogic clientLogic = new ClientLogic(); BE.Client client = clientLogic.GetClientByClientGuid(facility.ClientGuid); if (client.Email == email) { // to delete facility first delete related records in FacilityPhoto and FacilityOffering // !!! in the existing business model transaction scope is hard to implement !!! FacilityOfferingLogic facilityOfferingLogic = new FacilityOfferingLogic(); FacilityPhotoLogic facilityPhotoLogic = new FacilityPhotoLogic(); OfferingLogic offeringLogic = new OfferingLogic(); // delete related offerings var facilityOfferings = offeringLogic.GetOfferingsForFacility(facilityGuid); if (facilityOfferings.Count > 0) { facilityOfferings.ForEach(fo => { facilityOfferingLogic.DeleteFacilityOffering( new BE.FacilityOffering { FacilityGuid = facilityGuid, OfferingGuid = fo.OfferingGuid } ); }); } // delete related photos var facilityPhotos = facilityPhotoLogic.GetFacilityPhotosForFacilityByFacilityGuid(facilityGuid); if (facilityPhotos.Count > 0) { facilityPhotos.ForEach(fp => facilityPhotoLogic.DeleteFacilityPhoto(fp)); } facilityLogic.DeleteFacility(facility); success = true; } return success; }
private void SaveTypesOfCare(ListingViewModelEdit listing) { FacilityOfferingLogic fologic = new FacilityOfferingLogic(); // offerings (types of care) processing listing.TypeOfCareList.ToList().ForEach(tc => { var exists = fologic.GetFacilityOfferingByFacilityGuidOfferingGuid(listing.FacilityGuid, tc.TypeOfCareGuid); // checked but not present in database if (tc.Checked && exists == null) { fologic.InsertFacilityOffering(tc.ToFacilityOffering(listing.FacilityGuid)); } // not checked but present in database if (!tc.Checked && exists != null) { fologic.DeleteFacilityOffering(tc.ToFacilityOffering(listing.FacilityGuid)); } }); }