/// <summary> /// Inserts the source to hostel. /// </summary> /// <param name="hostelBookingSource">The hostel booking source.</param> /// <returns> /// the task /// </returns> public async Task InsertSourceToHostel(HostelBookingSource hostelBookingSource) { try { await this.hostelBookingSourceRepository.InsertAsync(hostelBookingSource); await this.publisher.EntityInserted(hostelBookingSource); } catch (DbUpdateException e) { var inner = (SqlException)e.InnerException; if (inner.Number == 547) { var target = "Unknown"; if (inner.Message.IndexOf("FK_HostelBookingSources_BookingSources") != -1) { target = "Source"; } throw new HostaliandoException(target, HostaliandoExceptionCode.InvalidForeignKey); } } }
/// <summary> /// Deletes the source to hostel. /// </summary> /// <param name="hostelBookingSource">The hostel booking source.</param> /// <returns> /// the task /// </returns> public async Task DeleteSourceToHostel(HostelBookingSource hostelBookingSource) { await this.hostelBookingSourceRepository.DeleteAsync(hostelBookingSource); }