Beispiel #1
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;
        }
Beispiel #2
0
        // contains styling
        protected void AddFacilityPhotoToListing(ListingViewModelEdit listing, bool generateEmpty)
        {
            FacilityPhotoLogic photologic = new FacilityPhotoLogic();
            var photos = photologic.GetFacilityPhotosForFacilityByFacilityGuid(listing.FacilityGuid).ToViewModelList();

            photos.ToList().ForEach(f =>
            {
                f.Uid = string.Format("{0}", f.FacilityPhotoGuid);
                f.CssStyle = "fieldRow";
            });
            if (generateEmpty)
            {
                //// add additional text boxes
                int limit = 20 - photos.Count;
                for (int i = 0; i < limit; i++)
                {
                    photos.Add(new FacilityPhotoViewModel { FacilityGuid = listing.FacilityGuid, Uid = string.Format("{0:00}", i), CssStyle = "hidden" });
                }
            }

            listing.FacilityPhotos = photos;
        }
Beispiel #3
0
 public List<DC.FacilityPhoto> GetFacilityPhotosForFacilityByFacilityGuid(Guid facilityGuid)
 {
     try
     {
         BL.FacilityPhotoLogic facilityPhotoLogic = new BL.FacilityPhotoLogic();
         List<BE.FacilityPhoto> entities = facilityPhotoLogic.GetFacilityPhotosForFacilityByFacilityGuid(facilityGuid);
         List<DC.FacilityPhoto> response = entities.ToDataContractList();
         return response;
     }
     catch (BE.FacilityPhotoException ex)
     {
         FC.DefaultFaultContract fault = new FC.DefaultFaultContract();
         fault.ErrorMessage = string.Format("Unable to find a FacilityPhoto with the given Facility");
         throw new FaultException<FC.DefaultFaultContract>(fault,
             new FaultReason(ex.Message));
     }
 }