public DC.FacilityOffering GetFacilityOfferingByFacilityGuidOfferingGuid(Guid facilityGuid, Guid offeringGuid)
 {
     try
     {
         BL.FacilityOfferingLogic facilityOfferingLogic = new BL.FacilityOfferingLogic();
         BE.FacilityOffering entity = facilityOfferingLogic.GetFacilityOfferingByFacilityGuidOfferingGuid(facilityGuid, offeringGuid);
         DC.FacilityOffering response = entity.ToDataContract();
         return response;
     }
     catch (BE.FacilityOfferingNotFoundException ex)
     {
         FC.FacilityOfferingFault fault = new FC.FacilityOfferingFault();
         fault.FacilityGuid = ex.FacilityGuid;
         fault.OfferingGuid = ex.OfferingGuid;
         fault.ErrorMessage = "FacilityOffering does not exsist in the database.";
         throw new FaultException<FC.FacilityOfferingFault>(fault,
             new FaultReason(ex.Message));
     }
     catch (Exception ex)
     {
         FC.FacilityOfferingFault fault = new FC.FacilityOfferingFault();
         fault.ErrorMessage = "Could not retrieve a specific FacilityOffering for unknown reasons.";
         throw new FaultException<FC.FacilityOfferingFault>(fault,
             new FaultReason(ex.Message));
     }
 }
 public List<DC.FacilityOffering> GetAllFacilityOffering()
 {
     try
     {
         BL.FacilityOfferingLogic facilityOfferingLogic = new BL.FacilityOfferingLogic();
         List<BE.FacilityOffering> entities = facilityOfferingLogic.GetAllFacilityOffering();
         List<DC.FacilityOffering> response = entities.ToDataContractList();
         return response;
     }
     catch (Exception ex)
     {
         FC.DefaultFaultContract fault = new FC.DefaultFaultContract();
         fault.ErrorMessage = "Unable to retrieve facilityOffering data.";
         throw new FaultException<FC.DefaultFaultContract>(fault,
             new FaultReason(ex.Message));
     }
 }
 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));
     }
 }
Exemple #4
0
 public void AddOfferingToFacility(Guid facilityGuid, Guid offeringGuid, bool isChecked)
 {
     try
     {
         BE.FacilityOffering joinRowToAdd = new BE.FacilityOffering(facilityGuid, offeringGuid, isChecked);
         BL.FacilityOfferingLogic joinLogic = new BL.FacilityOfferingLogic();
         joinLogic.InsertFacilityOffering(joinRowToAdd);
     }
     catch (Exception ex)
     {
         FC.FacilityOfferingFault fault = new FC.FacilityOfferingFault();
         fault.FacilityGuid = facilityGuid;
         fault.OfferingGuid = offeringGuid;
         fault.ErrorMessage = String.Format("Unable to insert offering '{0}' into facility '{1}'.",
             offeringGuid, facilityGuid);
         throw new FaultException<FC.FacilityOfferingFault>(fault,
             new FaultReason(ex.Message));
     }
 }
Exemple #5
0
 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));
     }
 }
Exemple #6
0
        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));
                }
            });
        }