Example #1
0
 public List<DC.FacilityPhoto> GetAllFacilityPhotoWithUndefined()
 {
     try
     {
         BL.FacilityPhotoLogic facilityPhotoLogic = new BL.FacilityPhotoLogic();
         List<BE.FacilityPhoto> entities = facilityPhotoLogic.GetAllFacilityPhotoWithUndefined();
         List<DC.FacilityPhoto> response = entities.ToDataContractList();
         return response;
     }
     catch (Exception ex)
     {
         FC.DefaultFaultContract fault = new FC.DefaultFaultContract();
         fault.ErrorMessage = "Unable to retrieve facilityPhoto data.";
         throw new FaultException<FC.DefaultFaultContract>(fault,
             new FaultReason(ex.Message));
     }
 }
Example #2
0
        public void DeleteFacilityPhoto(DC.FacilityPhoto request)
        {
            try
            {
                BL.FacilityPhotoLogic facilityPhotoLogic = new BL.FacilityPhotoLogic();
                BE.FacilityPhoto entity = request.ToBusinessEntity();
                facilityPhotoLogic.DeleteFacilityPhoto(entity);
            }
            catch (BE.FacilityPhotoNotFoundException ex)
            {
                FC.DefaultFaultContract fault = new FC.DefaultFaultContract();
                fault.ErrorMessage = String.Format(
                    "Unable to delete FacilityPhoto data. Data: {0}",
                    request.ToBusinessEntity().ToString());

                throw new FaultException<FC.DefaultFaultContract>(fault,
                    new FaultReason(ex.Message));
            }
        }
Example #3
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;
        }
Example #4
0
        private void SaveListingPhotos(IList<FacilityPhotoViewModel> photos)
        {
            FacilityPhotoLogic photologic = new FacilityPhotoLogic();
            foreach (var photo in photos)
            {
                // move to mapping
                var facilityphoto = new FacilityPhoto { FacilityGuid = photo.FacilityGuid, FacilityPhotoGuid = photo.FacilityPhotoGuid, PhotoUri = photo.PhotoUri ?? "" };
                // replace this with better check
                if (facilityphoto.PhotoUri.Length > 5 && facilityphoto.FacilityPhotoGuid == Guid.Empty)
                {// add case
                    photologic.InsertFacilityPhoto(facilityphoto);
                }

                if (string.IsNullOrEmpty(facilityphoto.PhotoUri) && facilityphoto.FacilityPhotoGuid != Guid.Empty)
                {// delete case
                    photologic.DeleteFacilityPhoto(facilityphoto);
                }

                if (facilityphoto.PhotoUri.Length > 5 && facilityphoto.FacilityPhotoGuid != Guid.Empty)
                {// update case
                    photologic.UpdateFacilityPhoto(facilityphoto);
                }
            }
        }
Example #5
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;
        }
Example #6
0
 public DC.FacilityPhoto GetFacilityPhotoByFacilityPhotoGuid(Guid facilityPhotoGuid)
 {
     try
     {
         BL.FacilityPhotoLogic facilityPhotoLogic = new BL.FacilityPhotoLogic();
         BE.FacilityPhoto entity = facilityPhotoLogic.GetFacilityPhotoByFacilityPhotoGuid(facilityPhotoGuid);
         DC.FacilityPhoto response = entity.ToDataContract();
         return response;
     }
     catch (BE.FacilityPhotoNotFoundException ex)
     {
         FC.FacilityPhotoFault fault = new FC.FacilityPhotoFault();
         fault.FacilityPhotoGuid = ex.FacilityPhotoGuid;
         fault.ErrorMessage = "FacilityPhoto does not exsist in the database.";
         throw new FaultException<FC.FacilityPhotoFault>(fault,
             new FaultReason(ex.Message));
     }
     catch (Exception ex)
     {
         FC.FacilityPhotoFault fault = new FC.FacilityPhotoFault();
         fault.ErrorMessage = "Could not retrieve a specific FacilityPhoto for unknown reasons.";
         throw new FaultException<FC.FacilityPhotoFault>(fault,
             new FaultReason(ex.Message));
     }
 }
Example #7
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));
     }
 }