Beispiel #1
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));
            }
        }
Beispiel #2
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 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);
                }
            }
        }