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); } } }
public void InsertFacilityPhoto(DC.FacilityPhoto request) { try { BL.FacilityPhotoLogic facilityPhotoLogic = new BL.FacilityPhotoLogic(); BE.FacilityPhoto entity = request.ToBusinessEntity(); facilityPhotoLogic.InsertFacilityPhoto(entity); } catch (BE.FacilityPhotoAlreadyExistsException ex) { FC.DefaultFaultContract fault = new FC.DefaultFaultContract(); fault.ErrorMessage = String.Format( "Unable to insert FacilityPhoto data. Data: {0}", request.ToBusinessEntity().ToString()); throw new FaultException<FC.DefaultFaultContract>(fault, new FaultReason(ex.Message)); } }